[IOS development compatibility] About synchronous ios6 and ios5 screen Rotation

Source: Internet
Author: User

About synchronous ios6 and ios5 rotating screens

As we all know, ios6 does not support shouldautorotatetointerfaceorientation and forcibly opens all the direction of the project, which will cause inconvenience to some projects, especially when rootcontroller is a landscape screen, if you place the image vertically, there will be obvious misplacement. This will happen in ios5, And the ios6 system will automatically detect it. Here is a brief introduction to my solution:

Step 1: (the default project is landscape, and only some controllers support full rotation)

Set project direction

Step 2:

Add the following content to the project's appdelegate file:

-(Nsuinteger) Application :( uiapplication *) Application supportedinterfaceorientationsforwindow :( uiwindow *) window {

Return uiinterfaceorientationmaskall;

}

Tell the Project to Support rotation in all directions-pave the way for the later support. If the project does not declare this and the first step does not open all directions, some screens will be misplaced.

Step 3:

Add

// Rotate the screen under ios5

-(Bool) shouldautorotatetointerfaceorientation :( uiinterfaceorientation) interfaceorientation {

Return uiinterfaceorientationislandscape (interfaceorientation );

}

// Rotate the screen under ios6

-(Bool) shouldautorotate {

Return yes;

}

-(Nsuinteger) supportedinterfaceorientations {

Return uiinterfaceorientationmasklandscape;

}

Add

-(Bool) shouldautorotatetointerfaceorientation :( uiinterfaceorientation) tointerfaceorientation {

Return yes;

}

 

-(Nsuinteger) supportedinterfaceorientations {

Return uiinterfaceorientationmaskall;

}

 

-(Bool) shouldautorotate {

Return yes;

}

In this way, the full-direction screen Rotation Problem of the two versions is well solved. Here, I will explain what will happen if this problem is not solved.

A: All directions of the project are enabled, that is, all directions of the first step are enabled. This is done normally under ios6, but the first controller in ios5 (not the default on the start page) the vertical screen will appear (of course, if you place the position in the vertical direction, * _ * will appear. I will not talk more about all this)

B: If the project direction is not declared in appdelegate, sometimes the screen will be stuck when the controller is rotating the screen, but the screen won't be able to be selected, and there will be serious dislocation.

Original http://www.jcsample.com/jcsample/archives_399.html

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.