代码之家  ›  专栏  ›  技术社区  ›  Utku Dalmaz

停止/暂停在tableview单元格类中创建的avplayer

  •  0
  • Utku Dalmaz  · 技术社区  · 7 年前

    我正在开发一个带有tableview的视频源应用程序。

    我创造 AVPlayer 对象,并在cellforitem中将playitem分类给它。一切都很好。

    viewDidDisappear 但是我不能访问tableview cell子类的AvPlayer对象来停止它。

    1 回复  |  直到 7 年前
        1
  •  1
  •   Shehata Gamal    7 年前

    你可以试试

    tableView.visibleCells.forEach {
       if let cell = $0 as? PostsWithVideoCustom , let player = cell.player { // assuming it's optional 
          // stop it here 
       }
    } 
    
    推荐文章