The iphone's horizontal screen vertical screen is developed in two ways for iOS system versions: one that is used before iOS 6 is a new mode of iOS6. The difference between the two is pretty big.
1:IOS6 usually uses shouldautorotatetointerfaceorientation to control the direction of a uiviewcontroller individually, which Viewcontroller supports rotation, You only need to override the Shouldautorotatetointerfaceorientation method. As the following example, when set, the screen is rotated to support only the horizontal screen conversion:-(BOOL) Shouldautorotatetointerfaceorientation: (uiinterfaceorientation) interfaceorientation {return uiinterfaceorientationislandscape (interfaceorientation); After IOS6, the following two methods are used to control the automatic rotation, namely:-(BOOL) shouldautorotate {NSLog (@ "Let me spin?"); return YES; }-(Nsuinteger) supportedinterfaceorientations {NSLog (@ "Let me rotate which direction"); return uiinterfaceorientationmaskallbutupsidedown; The system automatically calls the other two methods after the auto-rotation trigger: -(void) Willrotatetointerfaceorientation: (uiinterfaceorientation) tointerfaceorientation Duration: (NSTimeInterval ) Duration { [super Willrotatetointerfaceorientation:tointerfaceorientation duration:duration]; NSLog (@ "Going to spin?"); } -(void) Didrotatefrominterfaceorientation: (uiinterfaceorientation) frominterfaceorientation { [Super didrotatefrominterfaceorientation:frominterfaceorientation]; NSLog (@ "If you let me spin, I'm done!"); } 2: How to display a horizontal or vertical screen immediately when the program first starts if it is iOS6 before the device support direction set below can be modified in the app if it is iOS6 later, will be made as a hard condition, that is, if the code in the application can no longer be used in this direction 3: The legendary private API implements the way to toggle Viewcontroller Force horizontal screen if ([[Uidevice Currentdevice ] Respondstoselector: @selector (setorientation:)]) { [[Uidevice Currentdevice] Performselector: @selector (setorientation:) &N Bsp &NBSP withobject: (ID) uiinterfaceorientationlandscaperight];   4: Change the display mode of Xib when using Xib for interface design
About two ways to set up an iOS screen (reprint)