我目前有一个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
答案 0 :(得分:1)
问题是该单元格不是Web视图的委托,因此永远不会调用单元格中的Web视图委托方法。