Orientation management in UINavigationController in iOS 10 -
i have simple app, 3 uiviewcontrollers in uinavigationcontroller:
i wish first 2 uiviewcontrollers work in portrait orientation , last 1 work in landscape one.
i subclassed uinavigation controller , overrided 3 methods:
class navctrl: uinavigationcontroller { override var shouldautorotate: bool { return topviewcontroller?.shouldautorotate ?? super.shouldautorotate } override var supportedinterfaceorientations: uiinterfaceorientationmask { return topviewcontroller?.supportedinterfaceorientations ?? super.supportedinterfaceorientations } override var preferredinterfaceorientationforpresentation: uiinterfaceorientation { return topviewcontroller?.preferredinterfaceorientationforpresentation ?? super.preferredinterfaceorientationforpresentation } } in first 2 view controllers added:
override var shouldautorotate: bool { return false } override var supportedinterfaceorientations: uiinterfaceorientationmask { return .portrait } in last view have:
override var shouldautorotate: bool { return false } override var supportedinterfaceorientations: uiinterfaceorientationmask { return .landscapeleft } when run app 3 views support portrait orientation, last view doesn't work in landscape. put breakpoints shouldautorotate , supportedinterfaceorientations (uinavigationcontroller) there called once when app loads , again when rotate device not when view controller pushed nav controller.
i tried add line:
uiviewcontroller.attemptrotationtodeviceorientation() to viewdidload last view controller force orientation reload no luck.
do have idea make app match requirements?
thanks

Comments
Post a Comment