Supports horizontal screen rotation for iOS devices

Source: Internet
Author: User

Supports horizontal screen rotation for iOS devices

Ios devices support rotation methods:

1. Modify the info of the project. the value of "Supported interface orientations" in plist (generally, you can check the Taget-> General-> Deployment Info-> Device Orientation in the project to select Device Support ).

2. Implement the (application: supportedInterfaceOrientationsForWindow :) method in the AppDelegate file of the project. In this method, return the direction enumeration supported by the program.

3. To implement a ViewController that supports rotation after iOS6.0, you can use the following two methods:

-(BOOL) shouldAutorotate {// whether rotation is supported

 

Return YES;

}

-(NSUInteger) supportedInterfaceOrientations {// orientation of rotation supported

 

ReturnUIInterfaceOrientationMaskPortrait;

}

 

Extension:

If the program interface requires only vertical screens, but the webView pop-up video in the project requires horizontal screen playback, you can solve the problem by combining the above mentioned methods in 1st and 2.

Solution: Modify the project info. plist value so that it only supports the Portrait direction; then implement application: supportedInterfaceOrientationsForWindow: method, and return the UIInterfaceOrientationMaskAllButUpsideDown value in this method. In this way, even if a program is started on a horizontal screen on the iPhone 6 P or ipad, the screen will not appear, and video playback on the iPhone still supports horizontal screen.

The above questions are resolved:

You can modify info. plist to enable the device to support all directions, and change the screen width and height obtained by [UIScreen mainScreen]. bounds.

Implement application: supportedInterfaceOrientationsForWindow: The method supports all directions without changing the wide and high values corresponding to [UIScreen mainScreen]. bounds.

The conjecture caused by the above problem is not verified. If there is anything wrong, please correct it ....

 

 

 

 

 

 

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.