iOS6: supportedInterfaceOrientations not working (is invoked but the interface still rotates)

前端 未结 15 659
野趣味
野趣味 2020-11-29 04:09

In my app I have multiple views, some views need to support both portrait and landscape, while other views need to support portrait only. Thus, in the project summary, I ha

15条回答
  •  悲&欢浪女
    2020-11-29 04:32

    In my case I have UINavigationController and my view controller inside. I had to subclass UINavigationController and, in order to support only Portrait, add this method:

    - (NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
    }
    

    So in the UINavigationController subclass I need to check which orientation is supported by the current topViewController.

    - (NSUInteger)supportedInterfaceOrientations
    {
        return [[self topViewController] supportedInterfaceOrientations];
    }
    

提交回复
热议问题