iOS 6 - (BOOL)shouldAutorotate not getting called for navigation controllers pushed viewControllers

后端 未结 5 786
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-09 07:31

For my app rootViewController is navgationController.

I found that pushed controller\'s

-(BOOL)shouldAutorotate is not

5条回答
  •  无人共我
    2021-02-09 08:26

    You can check the following link, you need to create custom navigation to support should auto rotate

    http://mobileappdevpage.blogspot.in/2012/11/how-to-use-should-autorotateios-6-with.html

    The other way you can do this by creating category of UINaviagationController

    code for .h file is

    @interface UINavigationController (autorotation)
    
    -(BOOL)shouldAutorotate;
    -(NSUInteger)supportedInterfaceOrientations;
    

    and code for .m file is

    @implementation UINavigationController (autorotation)
    
    -(BOOL)shouldAutorotate
    {
    
        UIInterfaceOrientation interfaceOrientation = [UIApplication sharedApplication].statusBarOrientation;
        [self.topViewController shouldAutorotate];
        return YES;
    
    }
    
    -(NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskAll;
    
    }
    @end
    

提交回复
热议问题