ios - restricting autorotation on certain views -


my app contains 2 table view controllers. in first 1 want view able rotated left , right (in addition portrait mode), in second table view controller ( navigate after tapping cell first table) want viewed in portrait mode. tried code didn't work, keeps on rotating.

- (nsuinteger)supportedinterfaceorientations {     return uiinterfaceorientationmaskportrait; }  - (bool) shouldautorotate {     return no; } 

note: did enabled left/right/portrait orientation summary tab of project target. fix?

create category uinavigationcontroller include following methods:

(works both ios 6 , ios 5)

- (bool)shouldautorotate     {         return self.topviewcontroller.shouldautorotate;     }      - (nsuinteger)supportedinterfaceorientations     {         return self.topviewcontroller.supportedinterfaceorientations;     }      - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)tointerfaceorientation {         return [self.topviewcontroller shouldautorotatetointerfaceorientation:tointerfaceorientation];     } 

then implement these methods in controllers

first:

- (bool)shouldautorotate {     return yes; }  - (nsuinteger)supportedinterfaceorientations {     if (running_ipad) {         return uiinterfaceorientationmaskall;     }     else {         return uiinterfaceorientationmaskallbutupsidedown;     }; }  - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)tointerfaceorientation {     if (running_ipad) {         return yes;     }     else {         return tointerfaceorientation != uiinterfaceorientationmaskportraitupsidedown;     } } 

and second:

- (bool)shouldautorotate {     return no; }  - (nsuinteger)supportedinterfaceorientations {        return uiinterfaceorientationmaskportrait; }  - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)tointerfaceorientation {         return no; } 

the rotation settings of project should like:

settings


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -