Solution for single page horizontal screen in iOS vertical screen application

Source: Internet
Author: User

Yesterday, my friend asked me how to achieve in the vertical screen application, display a horizontal screen of the application, because has not done

I don't know, but I think there will be such an API, because I have this type of software installed on my phone

When I woke up this morning, I wanted to make a dome out, and it was customary to find the data and test whether it was available, but

Find all write not very clear, it is easy to achieve the desired effect, so want to re-write a

Hope to help the people who have this need. (This is no experience, it is to put together the information on the Internet,

If there is an error, please forgive me, there is a better way to tell me.

The effect of the implementation:

Most of the page is vertical screen, individual pages can be rotated mobile phone when the page changed to horizontal screen (in fact, the needs of friends is to enter

This page is a horizontal screen, do not know how to do it.

Implementation steps:

1. Enable the app to traverse the screen, the newly created default will be

2. Implement the following methods in the view (the navigation controller and the Tabbar controller can)

-(BOOL) shouldautorotate{    return  YES; -(Nsuinteger) supportedinterfaceorientations{    return  [self.viewControllers.lastObject Supportedinterfaceorientations];} -(uiinterfaceorientation) preferredinterfaceorientationforpresentation{    return  [ Self.viewControllers.lastObject preferredinterfaceorientationforpresentation];}

3. In a view controller that does not require a horizontal screen, implement the following methods

-(Nsuinteger) supportedinterfaceorientations{    return uiinterfaceorientationmaskportrait;} -(BOOL) shouldautorotate{    return NO; -(uiinterfaceorientation) preferredinterfaceorientationforpresentation{    return uiinterfaceorientationportrait;}

4, the need for a horizontal screen of the page does not require other processing on it.

Solution for single page horizontal screen in iOS vertical screen application

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.