How to force a UIViewController to Portrait orientation in iOS 6

后端 未结 16 1352
别那么骄傲
别那么骄傲 2020-11-22 06:03

As the ShouldAutorotateToInterfaceOrientation is deprecated in iOS 6 and I used that to force a particular view to portrait only, what is the c

16条回答
  •  难免孤独
    2020-11-22 06:43

    1) Check your project settings and info.plist and make sure that only the orientations you want are selected.

    2) add the following methods to your topmost view controller(navigation controller/tabbar controller)

    - (NSUInteger) supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskPortrait;
    
    }
    

    3) add the following methods to your app delegate

    - (NSUInteger) supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskPortrait;
    
    }
    
    - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
    {
        return UIInterfaceOrientationMaskPortrait;
    
    }
    

提交回复
热议问题