首页 文章

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

提问于
浏览
1

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

enter image description here

在.plist文件中:

enter image description here

在我的 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中我没有这样的行为 .

1 回答

  • 3

    试试这样,

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

相关问题