1

更新到 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 中我没有这样的行为。

4

1 回答 1

3

像这样试试

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeLeft;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return (UIInterfaceOrientationMaskLandscape);
}
于 2013-11-05T09:19:38.687 回答