objective c - How to disable autorotation in iOS 8 for a particular controller? -
objective c - How to disable autorotation in iOS 8 for a particular controller? -
-(bool)shouldautorotate { homecoming no; }
above method works 1 controller when there multiple viewcontrollers pushed on stack. want particular controller should displayed in portrait mode only.
- (void) viewwilltransitiontosize:(cgsize)size withtransitioncoordinator:(id<uiviewcontrollertransitioncoordinator>)coordinator { }
i have used above method suggested on stack overflow ios 8 not give desired result.
first, utilize -supportedinterfaceorientations
instead of -shouldautorotate
. -shouldautorotate
should used when must disallow autorotation based on factors determined @ runtime. know view controller back upwards portrait mode, there no runtime decision here.
next, navigation controller's delegate must implement -navigationcontrollersupportedinterfaceorientations:
method homecoming result of calling -supportedinterfaceorientations
on view controller @ top of navigation stack.
-(nsuinteger)navigationcontrollersupportedinterfaceorientations:(uinavigationcontroller *)navigationcontroller { homecoming navigationcontroller.topviewcontroller.supportedinterfaceorientations; }
an of import caveat: view controller pushed onto navigation stack has no command on initial interface orientation; current interface orientation. above technique prevent interface rotating orientation other portrait while view controller displayed.
ios objective-c ios8 uiinterfaceorientation
Comments
Post a Comment