For iOS horizontal and vertical screen setting (reprinted), ios reprinted
The horizontal screen and vertical screen of the iPhone are developed in two ways for the iOS system version: one is the use mode before iOS 6, and the other is the new mode of iOS6. The difference between the two is quite large.
1: shouldAutorotateToInterfaceOrientation is usually used before iOS6 to separately control the direction of a UIViewController. Which viewController needs to support rotation? You only need to override the shouldAutorotateToInterfaceOrientation method. In the following example, after setting, only horizontal screen conversion is supported when the screen is rotated:-(BOOL) shouldAutorotateToInterfaceOrientation :( UIInterfaceOrientation) interfaceOrientation {return UIInterfaceOrientationIsLandscape (interfaceOrientation );} after iOS6, use the following two methods to control automatic rotation:-(BOOL) shouldAutorotate {NSLog (@ "to prevent me from rotating? "); Return YES;}-(NSUInteger) supportedInterfaceOrientations {NSLog (@" "); return UIInterfaceOrientationMaskAllButUpsideDown;} after automatic rotation is triggered, the system automatically calls the other two methods:-(void) willRotateToInterfaceOrientation :( UIInterfaceOrientation) toInterfaceOrientation duration :( NSTimeInterval) duration {[super duration: toInterfaceOrientation duration: duration]; NSLog (@ "is it about to rotate? ");}-(Void) rotate :( UIInterfaceOrientation) fromInterfaceOrientation {[super didRotateFromInterfaceOrientation: fromInterfaceOrientation]; NSLog (@" if you want me to rotate, I have already completed the rotation! ");} 2: display the landscape screen or landscape screen immediately when the program is started for the first time. If it is before iOS6, the following device support direction can be modified in the application. If it is iOS6, it will be used as a hard condition, that is, if it is set later, the code in the application can no longer use this direction. 3. The legendary private API implements the option of switching the ViewController to force a horizontal screen. if ([[UIDevice currentDevice] respondsToSelector: @ selector (setOrientation :)]) {[[UIDevice currentDevice] performSelector: @ selector (setOrientation :) withObject :( id) UIInterfaceOrientationLandscapeRight];} 4: When xib is used for interface design, the xib display mode is changed.