【发布时间】:2015-01-15 22:30:32
【问题描述】:
我在旋转 youtube 视频时遇到问题。我将以下代码添加到我的应用程序中。它适用于 iOS 7。但是,它不适用于 iOS8。
在我的视图控制器中,我使用了以下代码:
if(IS_OS_6_OR_LATER){
// I use the following notification for iOS 7
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youTubeStarted:) latername:@"UIMoviePlayerControllerDidEnterFullscreenNotification" object:nil];//Notification
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youTubeFinished:) name:@"UIMoviePlayerControllerWillExitFullscreenNotification" object:nil];//Notification
}
if (IS_OS_8_OR_LATER) {
// I use the following notification for iOS 8
[[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];
}
-(void) youTubeStarted:(NSNotification*) notif {
//Handle event
AppDelegate* appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
appDelegate.fullScreenVideoIsPlaying = YES;
NSLog(@"start fullscreen");
}
-(void) youTubeFinished:(NSNotification*) notif {
AppDelegate* appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];//Notification
appDelegate.fullScreenVideoIsPlaying = NO;//Notification
NSLog(@"exit fullscreen");//Notification
}
-(BOOL) shouldAutorotate {
//Handle rotate
NSLog(@"AutoState");
return NO;
}
-(NSUInteger)supportedInterfaceOrientations{
//Handle rotate
NSLog(@"AutoState 1");
return UIInterfaceOrientationMaskPortrait;//Notification
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
//Handle rotate
NSLog(@"AutoState 2");
return UIInterfaceOrientationPortrait;//Notification
}
在 iOS 7 中,当视频在横向模式下播放时,我按下完成按钮,我看到日志“AutoState 1”显示,但是在 iOS 8 上运行时我没有看到此日志。你能帮我解决这个问题吗iOS 8?非常感谢
【问题讨论】:
-
请花时间正确格式化您的代码,以便于阅读。提供有关您的问题及其背景的更多信息。
-
@gareththegeek:对不起,因为我是新手。对此我感到非常抱歉
-
谁能帮帮我?请!!!!!!!
-
任何人!!!!帮助!!!!!!!!!!!!!!!!
标签: uiwebview rotation ios8 ios8.1