【问题标题】:How to show an activity Indicator inside a tableViewCell while its loading?如何在加载时在 tableViewCell 内显示活动指示器?
【发布时间】:2016-04-14 01:44:32
【问题描述】:

我目前有一个 tableView,其中一个单元格包含一个 webView。当 webView 加载时,我希望它显示一个活动指示器,但仅在该单元格中。目前,指示器显示但没有动画,当视频出现时,它不会隐藏并保持在视频的顶部。下面是 tableViewCell 的代码:

class VideoOnDetailCell: UITableViewCell {
      @IBOutlet weak var videoDetail: UIWebView!
      @IBOutlet weak var activityIndicator: UIActivityIndicatorView!

  func webViewDidStartLoad(webView: UIWebView) {
    activityIndicator.hidden = false
    activityIndicator.startAnimating()
    NSLog("The web view is starting to load")
  }
  func webViewDidFinishLoad(webView: UIWebView){
    activityIndicator.hidden = true
    activityIndicator.stopAnimating()
    NSLog ("The web view has finished loading")

  }
}

这里是 cellForRowAtIndexPath:

  let cell = tableView.dequeueReusableCellWithIdentifier("videoDetail", forIndexPath: indexPath) as!
      VideoOnDetailCell

      cell.videoDetail.allowsInlineMediaPlayback = true
      cell.videoDetail.loadHTMLString("<iframe width=\"\(cell.videoDetail.frame.width)\" height=\"\(200)\" src=\"\(videoURL[indexPath.row])/?&playsinline=1\" frameborder=\"0\" allowfullscreen></iframe>", baseURL: nil)
      self.DetailTvTableView.rowHeight = 200
      return cell

【问题讨论】:

    标签: swift uitableview uiwebview uiactivityindicatorview


    【解决方案1】:

    问题是单元格不是网络视图的委托,因此单元格中的网络视图委托方法永远不会被调用。

    【讨论】:

    • 好的,如何将单元格设置为委托?
    • cell.videoDetail.delegate = cell
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-09
    相关资源
    最近更新 更多