Project needs, only one interface needs horizontal screen display, the other all only support vertical screen display can, online data many, but tried all not good, and finally found because my project Uiviewcontroller outer layer is Uinavigationveiwcontroller, It is not possible to overload supportedinterfaceorientations and Shouldautorotate methods only in Uiviewcontroller.
The following is a description of the setup steps: (Reference http://www.cocoachina.com/bbs/read.php?tid-244095.html)
Step 1: Set the supported interface orientations for all supported orientations in Info.plist, I set this up:
Step 2: Add attributes to the custom Navigationviewcontroller:
@property (nonatomic, assign) BOOL Supportlandscape;
Initialization
-(ID) init{if (self = [super init]) {[Self setup];} return self;} -(void) setup{//other settings ... Self.supportlandscape = NO;}
Overloaded Supportedinterfaceorientations Method:
-(Uiinterfaceorientationmask) Navigationcontrollersupportedinterfaceorientations: (UINavigationController *) navigationcontroller{ if (self.supportlandscape) { return uiinterfaceorientationmaskportrait | Uiinterfaceorientationmasklandscaperight; } else{ return uiinterfaceorientationmaskportrait;} }
Step 3: All Viewcontroller in my project are controlled by Navigationcontroller, so just set it up in a viewcontroller that needs to support a horizontal screen:
-(void) Viewdidappear: (BOOL) animated{ [Slidenavigationcontroller sharedinstance].supportlandscape = YES;} -(void) Viewdiddisappear: (BOOL) animated{ [Slidenavigationcontroller sharedinstance].supportlandscape = NO;}
Pro-Test Use ~
iOS screen set vertical screen, individual interface force horizontal screen