ios - How to lock orientation just for one view controller? -
can set portrait orientation , lock orientation in 1 controller? i did try: override func supportedinterfaceorientations() -> int { return int(uiinterfaceorientationmask.portrait.rawvalue) } override func shouldautorotate() -> bool{ return false } but doesn't me. must add else? this code should work: override func supportedinterfaceorientations() -> int { return int(uiinterfaceorientationmask.portrait.rawvalue) } override func shouldautorotate() -> bool{ return false } override func preferredinterfaceorientationforpresentation() -> uiinterfaceorientation { return uiinterfaceorientation.portrait } if working you, suppose controller in controller( uinavigationcontroller , uitabbarcontroller , uisplitviewcontroller ). in case need use code in parent controller. if navigation controller contain more 1 view controller, , need disable orientation of them, need inherit uinavigationcontroller