I can't understand rotation mechanism in iOS6

前端 未结 3 1915
予麋鹿
予麋鹿 2021-02-10 06:33

My app has view controllers subclassing shouldautorotateToInterfaceOrientation. And in it, I decides each view\'s rotation. This works correctly. But in iOS6, t

3条回答
  •  猫巷女王i
    2021-02-10 06:52

    When you use UINavigationController or UITabbarViewController - application always does what they say in their shouldAutorotate, supportedInterfaceOrientations methods.

    You can add a category for them to redirect these methods to the controller they currently display. Like this:

     @implementation UINavigationController (Rotation_IOS6)
    -(BOOL)shouldAutorotate
    {
        return [[self.viewControllers lastObject] shouldAutorotate];
    }
    
    -(NSUInteger)supportedInterfaceOrientations
    {
        return [[self.viewControllers lastObject] supportedInterfaceOrientations];
    }
    
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
    {
        return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
    }
    @end
    

    Similar for UITabbarViewController.

提交回复
热议问题