iOS 6自动轮换问题 - supportedInterfaceOrientations返回值不受尊重

flo*_*vdu 10 iphone objective-c ipad autorotate ios6

我有一个应用程序,我有一个UINavigationController子类作为我的rootViewController.我有一个UITableViewController允许用户编辑一些设置,它应该始终处于纵向模式.将MoviePlayer组件推送到导航控制器后,我的应用程序还需要支持所有其他方向.

UITableViewController子类有此实现supportedInterfaceOrientations的:

- (NSUInteger)supportedInterfaceOrientations {
    LLog();
    return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)

logging命令告诉我实际调用它.

问题是没有遵守返回值,即当我转动设备时屏幕转向横向.

如何使设置视图始终以纵向显示,但允许更改视频查看器的方向?

更多信息:我的UINavigationController子类不会覆盖shouldAutorotate或supportedInterfaceOrientations.我没有实施

   - (NSUInteger)application:(UIApplication *)application 

supportedInterfaceOrientationsForWindow:(UIWindow *)window
Run Code Online (Sandbox Code Playgroud)

我的AppDelegate中的方法,我已启用目标摘要中的所有方向.

Min*_*gas 17

我有一个问题,ViewControllers导航堆栈中的一些支持所有方向,一些只有肖像,但UINavigation控制器返回所有应用程序支持的方向,这个小黑客帮助我.

@implementation UINavigationController (iOS6OrientationFix)

-(NSUInteger) supportedInterfaceOrientations {
    return [self.topViewController supportedInterfaceOrientations];
}

@end
Run Code Online (Sandbox Code Playgroud)

  • 感谢发布,花了一天时间试图让这个工作,这是一个很好的解决方法@Mindaugas.认为苹果公司已经放弃了这一点. (2认同)