我在 iOS 6 中也遇到过类似的问题。这背后的原因是,当在 iOS6 版本以外的版本中播放 YouTube 视频时,没有调用viewWillDisappear方法。但在 iOS6 中,每次播放 YouTube 视频时都会调用此方法。这可能是操作系统级别的错误,但我不确定。
但是,我已经修复了它,步骤如下。
添加全屏进入和退出通知,使用布尔属性,并相应地更新它。
// Notification when the player moves to full screen
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youTubeVideofullScreen:) name:@"UIMoviePlayerControllerDidEnterFullscreenNotification" object:nil];
// Notification when the player exit from full screen.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youTubeVideoExit:) name:@"UIMoviePlayerControllerDidExitFullscreenNotification" object:nil];
- (void)youTubeVideofullScreen:(id)sender {
//Update flag.
isFullscreen = TRUE;
}
- (void)youTubeVideoExit:(id)sender {
//Update flag.
isFullscreen = FALSE;
}
- (void)viewWillDisappear:(BOOL)animated {
//Now you can use that flag and avoid the code execution which is interrupting the video
if(!isFullscreen) {
[super viewWillDisappear:animated];
}
}
希望对您有所帮助。