本文介绍了iOS 6自动轮换问题 - supportedInterfaceOrientations返回值不受尊重的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've got an app where I have a UINavigationController subclass as my rootViewController. I've got a UITableViewController that lets the user edit some settings, it should always be in portrait mode. My app also needs to support all other orientations after I push a MoviePlayer component onto the navigation controller.

UITableViewController 子类具有supportedInterfaceOrientations的这种实现:

The UITableViewController subclass has this implementation of supportedInterfaceOrientations:

- (NSUInteger)supportedInterfaceOrientations {
    LLog();
    return UIInterfaceOrientationMaskPortrait;
}

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

The logging command tells me that this gets actually called.

问题在于没有遵守返回值,即当我转动设备时屏幕变为横向。

The problem is that the return value is not respected, i.e. the screen turns to landscape orientation when I turn the device.

什么我是否可以使设置视图始终以纵向显示但允许更改视频查看器的方向?

What can I do to make the settings view always show in portrait but allow orientation changes for the video viewer?

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

More information: my UINavigationController subclass doesn't override shouldAutorotate or supportedInterfaceOrientations. I haven't implemented

   - (NSUInteger)application:(UIApplication *)application 

supportedInterfaceOrientationsForWindow:(UIWindow *)window

我的 AppDelegate 中的

方法我启用了所有目标摘要中的方向。

method in my AppDelegate and I have enabled all orientations in the target summary.

推荐答案

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

I had issue that some ViewControllers in the navigation stack support all the orientations, some only portrait, but UINavigation controller was returning all app supported orientations, this little hack helped me.

@implementation UINavigationController (iOS6OrientationFix)

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

@end

这篇关于iOS 6自动轮换问题 - supportedInterfaceOrientations返回值不受尊重的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 08:03