Two ways to set up the iOS screen (reprint)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.