ios - Fix orientation on iPad -


my app requires portrait , portraitupsidedown. in target's deployment info checked these two. in info.plist 4 available. xcode wouldn't let me build when deleted landscapes info-plist, saying needed support four. after running app through testfligh, still returns landscape although unchecked in deployment info. how can rid of this?

you "allow" 4 options in settings, control orientation yourself.

i'd create custom uinavigation controller inside (swift):

import uikit  class mycustomnavigationcontroller: uinavigationcontroller {     override func supportedinterfaceorientations() -> uiinterfaceorientationmask {         return (visibleviewcontroller?.supportedinterfaceorientations())!     }      override func shouldautorotate() -> bool {         return (visibleviewcontroller?.shouldautorotate())!     } } 

then, in each of viewcontrollers want force particular orientation, include this:

override func supportedinterfaceorientations() -> uiinterfaceorientationmask {     return uiinterfaceorientationmask.landscape // or portrait }  override func shouldautorotate() -> bool {     return true } 

this way can allow orientations, still maintain control on views themselves. if want views same (e.g. landscape), create custom base class of view controllers second set of code in it, , wouldn't have include in each individual vc.


Comments