XCDYouTubeVideoPlayerViewController:旋转到 UIDeviceOrientationPortrait 时退出全屏

XCDYouTubeVideoPlayerViewController: Exit fullscreen when rotate to UIDeviceOrientationPortrait

我将 XCDYouTubeKit 库用于我的 iOS 项目。我使用代码显示非全屏模式的视频:

self.videoPlayer = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier:self.youtubeID];
[self.videoPlayer presentInView:self.videoView];
[self.videoPlayer.moviePlayer play];

当 iPhone 旋转到横向模式时,我将全屏视频设置为捕捉旋转电流 ViewController:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
if (fromInterfaceOrientation == UIDeviceOrientationPortrait) {
    [self.videoPlayer.moviePlayer setFullscreen:YES animated:NO];

}

但是我如何在全屏视频模式下捕捉旋转 XCDYouTubeVideoPlayerViewController? 谢谢


我的决定

在这个 class 我添加了 viewDidLoad 观察者

[[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(handleDidChangeStatusBarOrientationNotification:)
                                                 name:UIApplicationDidChangeStatusBarOrientationNotification
                                               object:nil];

并执行

- (void)handleDidChangeStatusBarOrientationNotification:(NSNotification *)notification; {

    if ([self.videoPlayer.moviePlayer isFullscreen] && [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait) {

        [self.videoPlayer.moviePlayer setFullscreen:NO animated:YES];

    }
}

我认为获取此信息的最简单方法是继承 XCDYouTubeVideoPlayerViewController 并覆盖 didRotateFromInterfaceOrientation: and/or viewWillTransitionToSize:withTransitionCoordinator: