我正在开发一个带有tableview的视频源应用程序。
我创造 AVPlayer 对象,并在cellforitem中将playitem分类给它。一切都很好。
AVPlayer
viewDidDisappear 但是我不能访问tableview cell子类的AvPlayer对象来停止它。
viewDidDisappear
你可以试试
tableView.visibleCells.forEach { if let cell = $0 as? PostsWithVideoCustom , let player = cell.player { // assuming it's optional // stop it here } }