disable autorotate on a single UIViewController in iOS6

前端 未结 5 1869
自闭症患者
自闭症患者 2020-12-01 06:43

I have a project using UINavigationController and segues working properly good, all of them rotate correctly, the thing is... I just want to disabl

5条回答
  •  孤城傲影
    2020-12-01 07:10

    Gonna complete GayleDDS's answer for the newbies just added a subclass of UINavigationController as he suggested like this:

    #import "UINavigationController.h"
    #import "MonthCalendarVC.h"
    
    @implementation UINavigationController (overrides)
    - (BOOL)shouldAutorotate
    {
        id currentViewController = self.topViewController;
    
        if ([currentViewController isKindOfClass:[MonthCalendarVC class]])
            return NO;
    
        return YES;
    }
    @end
    

    MonthCalendarVC is the viewController I want to be just in portrait mode (fixed), then just added the import to my appdelegate.m

    #import "UINavigationController.h"
    

    and that's it

提交回复
热议问题