Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 切换到选项卡栏中的其他选项卡后,原始VC中的视频将继续播放_Ios_Swift_Video_Uitabbarcontroller_Uitabbar - Fatal编程技术网

Ios 切换到选项卡栏中的其他选项卡后,原始VC中的视频将继续播放

Ios 切换到选项卡栏中的其他选项卡后,原始VC中的视频将继续播放,ios,swift,video,uitabbarcontroller,uitabbar,Ios,Swift,Video,Uitabbarcontroller,Uitabbar,我目前有一个正在播放视频的视图控制器。当我单击选项卡栏中的选项卡时,我切换到新的VC,但原始视频中的音频仍在播放。有没有办法停止音频 谢谢大家! 召唤 在ViewWillEnglish或ViewDidEnglish中,在第一个viewController中。试试这个,对我有用: override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) let center = C

我目前有一个正在播放视频的视图控制器。当我单击选项卡栏中的选项卡时,我切换到新的VC,但原始视频中的音频仍在播放。有没有办法停止音频

谢谢大家!


召唤


在ViewWillEnglish或ViewDidEnglish中,在第一个viewController中。

试试这个,对我有用:

override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)

    let center = CGPoint(x: postsTableView.center.x + postsTableView.contentOffset.x,y: postsTableView.center.y + postsTableView.contentOffset.y)
    
    guard let centerIndex = self.postsTableView.indexPathForRow(at: center) else {return}
    print("center point - \(center)")
    print("centerIndex - \(centerIndex.row)")
    let autoPlayCell = postsTableView.cellForRow(at: centerIndex) as? allPostsCell
    autoPlayCell?.vedioView.player?.pause()
}
override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)

    let center = CGPoint(x: postsTableView.center.x + postsTableView.contentOffset.x,y: postsTableView.center.y + postsTableView.contentOffset.y)
    
    guard let centerIndex = self.postsTableView.indexPathForRow(at: center) else {return}
    print("center point - \(center)")
    print("centerIndex - \(centerIndex.row)")
    let autoPlayCell = postsTableView.cellForRow(at: centerIndex) as? allPostsCell
    autoPlayCell?.vedioView.player?.pause()
}