iphone - Orientation should change only for the selected viewcontroller -
in app, 4 viewcontrollers navigates next next in potrait mode, added coverflow in final viewcontroller, , when simulator rotated should go landscape.i selected orientations in plist execpt upsidedown orientation, coverflow works fine in landscape, other viewcontrollers goes landscape when rotatad, need these viewcontrollers in potrait simulator rotated.i tried many codes like,
shouldautorotate , supportedinterfaceorientations. but doesn't clear solution towards iam expecting, if ideas , thankfull.
add new objective-c class (subclass of uinavigationcontroller) , add following code .m files
-(nsuinteger)supportedinterfaceorientations { nslog(@"supportedinterfaceorientations = %d ", [self.topviewcontroller supportedinterfaceorientations]); return [self.topviewcontroller supportedinterfaceorientations]; } -(bool)shouldautorotate { return self.topviewcontroller.shouldautorotate; } -(bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation { // not need method if not supporting earlier ios versions return [self.topviewcontroller shouldautorotatetointerfaceorientation:interfaceorientation]; } after added new classes go viewcontroller classes , make following changes
- (bool)shouldautorotate // ios 6 autorotation fix { return yes; } - (nsuinteger)supportedinterfaceorientations // ios 6 autorotation fix { return uiinterfaceorientationmaskall; } - (uiinterfaceorientation)preferredinterfaceorientationforpresentation // ios 6 autorotation fix { return uiinterfaceorientationportrait; } - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)tointerfaceorientation { return yes; } 
in shouldautorotate , shouldautorotatetointerfaceorientation: return yes if want viewcontroller supporting multiple orientation else return no , in houldautorotatetointerfaceorientation: method pass orintation want specific viewcontroller , repeat same view controllers .
reason of doing this:-
1:although can change preferredinterfaceorientationforpresentation: of viewcontroller specific orientation since using uinavigationcontroller need override supportedinterfaceorientations uinavigationcontroller
2:in order override supportedinterfaceorientations uinavigationcontroller have subclassed uinavigationcontroller , modified method related uinavigation orientation.
hope !
Comments
Post a Comment