仅限风景的应用程序仍在iOS7中自动镜像到肖像

更新到iOS7后,我的应用程序显示自动旋转。 我希望它是一个仅限风景的应用程序,因此,我按如下方式设置所有内容:在iOS6中很好。

在此处输入图像描述

在.plist文件中:

在此处输入图像描述

在我的MainWindow控制器中

 -(BOOL)shouldAutorotate { return NO; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; } 

AppDelegate.m称之为:

  MainViewController* mainViewController = [[MainViewController alloc] init]; // Create the navigation controller UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:mainViewController]; [navController setNavigationBarHidden:NO]; [[self window] setRootViewController:navController]; 

但是当我旋转设备时,应用程序仍然以纵向模式自动旋转。 在iOS 6中我没有这样的行为。

试试这样,

 - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationLandscapeLeft; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; } - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { return (UIInterfaceOrientationMaskLandscape); }