Can't auto rotate in iOS 6

后端 未结 4 1478
温柔的废话
温柔的废话 2021-01-17 06:26

In an app i\'m maintaining there\'s a rotate that should happen in portrait and portraitupsidedown mode. (all the rotation are enabled in the summary panel.)



        
4条回答
  •  醉梦人生
    2021-01-17 06:45

    My application targeted from IOS 5. I used shouldAutorotateToInterfaceOrientation method (by default) for IOS 5 device. And categories UINavigationController to handle the orientation for IOS 6.

    #import "UINavigationController+Rotation_IOS6.h"
    
        @implementation UINavigationController (Rotation_IOS6)
    
        -(BOOL)shouldAutorotate
        {
    
                return YES;
        }
    
        -(NSUInteger)supportedInterfaceOrientations
        {
    
            return UIInterfaceOrientationMaskAll;
        }
    
        - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
        {
            if([self.visibleViewController isMemberOfClass:NSClassFromString(@"SampleViewController")])
            {
                return UIInterfaceOrientationMaskLandscape | UIInterfaceOrientationMaskPortraitUpsideDown | UIInterfaceOrientationMaskPortrait;
            }
            return UIInterfaceOrientationPortrait;
    
        }
    
        @end
    

提交回复
热议问题