在iOS 8中输入视频时旋转

Eli*_*oMB 4 objective-c nsnotificationcenter ios ios8

我在iOS 7中实现了这个代码并且工作得很好,但是在iOS 8中它不起作用

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youTubeStarted:) name:@"UIMoviePlayerControllerDidEnterFullscreenNotification" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youTubeFinished:) name:@"UIMoviePlayerControllerWillExitFullscreenNotification" object:nil];

-(void)youTubeStarted{
    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
    appDelegate.fullScreenVideoIsPlaying = YES;
}

-(void)youTubeFinished{
    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
    appDelegate.fullScreenVideoIsPlaying = NO;
}
Run Code Online (Sandbox Code Playgroud)

我已经尝试将UIMoviePlayerControllerDidEnterFullscreenNotification更改为MPMoviePlayerWillEnterFullscreenNotification.没有运气

还有别的办法吗?

编辑

看看我在iOS 8.1中使用NorthBlast的答案会发生什么.它与iOS 8.0和iOS 8.0.2完美配合

在此输入图像描述

val*_*u17 5

好的,这是一个解决方案,我现在正在使用..我先检查哪个操作系统正在运行该设备然后使用适当的NSNotificationCenter :)

#define IS_OS_6_OR_LATER    ([[[UIDevice currentDevice] systemVersion] floatValue] >= 6.0)
#define IS_OS_8_OR_LATER    ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)

if(IS_OS_6_OR_LATER){

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youTubeStarted:) name:@"UIMoviePlayerControllerDidEnterFullscreenNotification" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youTubeFinished:) name:@"UIMoviePlayerControllerWillExitFullscreenNotification" object:nil];

}

if (IS_OS_8_OR_LATER) {

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youTubeStarted:) name:UIWindowDidBecomeVisibleNotification object:self.view.window];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youTubeFinished:) name:UIWindowDidBecomeHiddenNotification object:self.view.window];

}
Run Code Online (Sandbox Code Playgroud)

我希望它有所帮助!