As title, I'm wondering if it's possible to lock orientation programmatically in iOS 9 now? This is critical to my app but I can't find a way to do it. Thanks.
            Asked
            
        
        
            Active
            
        
            Viewed 8,385 times
        
    5
            
            
        - 
                    http://stackoverflow.com/questions/26357162/how-to-force-view-controller-orientation-in-ios-8 – GriffeyDog Sep 14 '15 at 18:54
- 
                    According to http://stackoverflow.com/questions/32684922/ios9-alternative-to-uidevice-currentdevice-setvalue-to-force-orientation , it is not possible in iOS 9. – David Lara Oct 29 '15 at 17:50
1 Answers
6
            
            
        Use supportedInterfaceOrientations and preferredInterfaceOrientationForPresentation used to manage orientation for example
-(UIInterfaceOrientationMask)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
    return UIInterfaceOrientationPortrait;
}
 
    
    
        Oswaldo Leon
        
- 261
- 3
- 12
- 
                    your viewcontroller inside in navegationController or tabbarcontroller? – Oswaldo Leon Jan 25 '16 at 04:37
- 
                    inside a navigation controller, which is, inside tabbarcontroller. – AbdulMomen عبدالمؤمن Apr 23 '16 at 11:34
- 
                    
- 
                    Helped me to find out what the problem was. The navigation controller was athorizing all masks – The Windwaker Sep 05 '16 at 09:47
- 
                    If the viewcontroller is under a navigationController, you need to add a class for the navigationController and put the code above into the navigationController's class. – flame3 Feb 25 '17 at 12:10
