【发布时间】:2017-11-09 04:59:35
【问题描述】:
我有一个 TableView 单元格,其中一些单元格上有视频,这些视频设置为在我滚动时自动播放,并且一个单元格有一个可以正确播放的视频,我知道当前索引行工作正常。我想知道的是如何从 UiTableViewCell 中获取当前可见行?这样我就可以在用户滚动时停止视频。这是我的代码
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "MyCellTVC", for: indexPath) as! MyCellTVC
let movieURL = URL(string: streamsModel.stream_image_string[indexPath.row])
cell.videoCapHeight.constant = CGFloat(Float(cell.pic_height!))
cell.playerView = AVPlayer(url: movieURL!)
streamsModel.MyAVPlayer.player = cell.playerView
streamsModel.MyAVPlayer.view.frame = cell.videoView.bounds
cell.videoView.addSubview(streamsModel.MyAVPlayer.view)
controller.addChildViewController(streamsModel.MyAVPlayer)
streamsModel.MyAVPlayer.player?.play()
// I would like to get the current visible view row
// here so I can do some logic
return cell
}
我想在那里获取行号,因为我想在那里做一些逻辑,因为我可以访问 TableView (cell dequeueReusableCell) 中的 UILabels。
【问题讨论】:
标签: swift uitableview nsindexpath