IOS _ screen orientation supported by mobile phones

Source: Internet
Author: User

IOS _ screen orientation supported by mobile phones

The settings support two levels of screen orientation: app-level and viewController-level.

 

You can set the app level in [target]-[general]-[device orientation], for example:

By default, Upside Down is not selected, and others are selected.

(Why is Upside Down not recommended? Because the iPhone phone app does not support Upside Down. If your app supports Upside Down, if the user Upside goes Down when using your app, the call screen will be reversed and the user experience will be poor. We do not recommend you select Upside Down for Apple, which has always paid attention to user experience)

 

The viewController level is set in each viewController.

Note that viewController settings are restricted by app-level settings, that is, viewController can only set one or more screen directions at the app level, it cannot be set if it is not selected. For example, if the Upside Down option is not selected, viewController cannot set the Upside Down direction.

 

How can I set the screen direction in viewController?

Before iOS6:

 

// Set the screen to only vertical-(BOOL) shouldAutorotateToInterfaceOrientation :( UIInterfaceOrientation) interfaceOrientation {return (interfaceOrientation = UIInterfaceOrientationPortrait );}

Since iOS6, the above method has been abandoned and there are three new methods:

 

 

// Does not support screen rotation-(BOOL) shouldAutorotate {return NO;} // only supports vertical-(NSUInteger) supportedInterfaceOrientations {return UIInterfaceOrientationPortrait ;} // The screen is loaded vertically at the beginning. //-(UIInterfaceOrientation) preferredInterfaceOrientationForPresentation {// return UIInterfaceOrientationPortrait ;//}

If the versions earlier than iOS6 correspond to each other, the discarded method also needs to be added.

 

However, at the beginning of iOS8.3, In the viewController with UIAlertView, the pop-up UIAlertView will crash. The Log information is as follows:

 

Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [_UIAlertShimPresentingViewController shouldAutorotate] is returning YES'

 

After reading the official documentation, we found that the supportedInterfaceOrientations method returned values of the UIInterfaceOrientationMask type, so we should use UIInterfaceOrientationMaskPortrait. The UIInterfaceOrientationMask type is available from iOS6, but only iOS8.3 will crash.

 

As for the preferredInterfaceOrientationForPresentation method, the returned value is still of the old UIInterfaceOrientation type.

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.