我有一个推动第二个UIViewcontroller的UIViewcontroller。第二个UIViewcontroller有一个UIWebview:一些文本,以及来自youtube url(嵌入)的一些视频。当我点击视频时,播放器正在打开,屏幕仍然处于纵向模式,而不是旋转到横向。
视频在ios5上正常运行,功能如下:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieIsPlaying:) name:@"UIMoviePlayerControllerDidEnterFullscreenNotification" object:nil];
- (void)movieIsPlaying:(NSNotification *)notification
{
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight | UIInterfaceOrientationLandscapeLeft animated:NO];
}
只有ios6才会出现问题。
知道如何解决这个问题吗?
答案 0 :(得分:1)
以下是Apple的iOS SDK,XCode4.5 +的引用(参见UIViewController
类参考,处理视图轮换):
在iOS 6中,您的应用支持在您的应用中定义的界面方向 app的Info.plist文件。视图控制器可以覆盖 supportedInterfaceOrientations方法限制支持的列表 取向。通常,系统仅在根上调用此方法 视图控制器的窗口或视图控制器呈现填充 整个屏幕;子视图控制器使用的部分 由父视图控制器为它们提供的窗口不再 直接参与有关轮换的决定 支撑。
同样在iOS6中,shouldAutorotateToInterfaceOrientation:
类的UIViewController
方法已被弃用。
因此,在根视图控制器中,执行ff:
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
顺便说一句,“根视图控制器”是您设置为appDelegate窗口对象的rootViewController的任何UIViewController
子类。您通常在appDelegate的application:didFinishLaunchingWithOptions:
方法中执行此操作。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.rootViewController = [FFDashboardController create];
[self.window makeKeyAndVisible];
return YES;
}
还要检查此Answer