IO6 doesn't call -(BOOL)shouldAutorotate

后端 未结 2 1344
失恋的感觉
失恋的感觉 2021-01-01 06:58

I have some views in my app that I don\'t want to suport orientation. In didFinishLaunchingWithOptions I add navigation:

...
UINavigationControl         


        
相关标签:
2条回答
  • 2021-01-01 07:26

    It's because neither UITabBarcontroller nor UINavigationController is passing shouldAutorotate to its visible view controller. To fix that you may subclass either UITabBarController or UINavigationController and forward shouldAutorotate from there:

    In your subclassed UITabBarController add:

    - (BOOL)shouldAutorotate
    {
        return [self.selectedViewController shouldAutorotate];
    }
    

    In your subclassed UINavigationController add:

    - (BOOL)shouldAutorotate
    {
        return [self.visibleViewController shouldAutorotate];
    }
    
    0 讨论(0)
  • 2021-01-01 07:48

    in the AppDelegate:

    - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window  // iOS 6
    {
    
    return UIInterfaceOrientationMaskAll;
    
    
    }
    

    in your ViewController:

    - (BOOL)shouldAutorotate {
    return YES;
    }
    
    - (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
    }
    
    0 讨论(0)
提交回复
热议问题