Landscape-only app still autorotates to portrait in iOS7

冷暖自知 提交于 2019-12-31 04:24:05

问题


After updating to iOS7, my app shows autorotation. I want it to be a landscape-only app and, accordingly, I set up everything as follows: In iOS6 was fine.

In .plist file:

In my MainWindow controller

-(BOOL)shouldAutorotate
{
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

The AppDelegate.m call it as:

 MainViewController* mainViewController = [[MainViewController alloc] init];
    // Create the navigation controller
    UINavigationController *navController = [[UINavigationController alloc]
                                             initWithRootViewController:mainViewController];


    [navController setNavigationBarHidden:NO];
    [[self window] setRootViewController:navController];

But still the app autorotate in portrait mode when I rotate the device. In iOS 6 I had not such behavior.


回答1:


Try like this,

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeLeft;
}

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


来源:https://stackoverflow.com/questions/19785333/landscape-only-app-still-autorotates-to-portrait-in-ios7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!