Projects only support portrait screens, and specific pages support landscape screens.

Source: Internet
Author: User
Project Overview: 1. the project has uitabbarcontroller to manage multiple uinavigationcontrollers. Each uinaviagitioncontroller is in charge of multiple uiviewcontrollers. 2. the project is developed by multiple people to use multiple uistoryboards without mutual interference. project requirements: 1. in the project, only the playback video page allows the user to play the video on the horizontal screen, but not the page or the horizontal screen; 2. the title must be displayed on the playback page. You can use the push method to jump to the page. The page cannot be displayed in the modal mode. 3. when the horizontal screen of the playback page is displayed, the navigation bar is automatically hidden. You can click the screen to restore the navigation bar and click again to hide it again. 4. after playing the video, return to the upper-level page, which can only be displayed on a portrait screen. Solution: 1. select the project in three directions. 1. select a project; 2. select tagets; 3. select General; 4. select landscape left and landscape right, for example, :) 2. build the uitabbarcontroller controller subclass and write the following code in the Controller: // whether to allow steering-(bool) shouldautorotate
{
Return self. viewcontrollers. firstobject. shouldautorotate;
} // Which directions can be transferred-(uiinterfaceorientationmask) supportedinterfaceorientations
{
Return [self. viewcontrollers. firstobject supportedinterfaceorientations];
}

-(Uiinterfaceorientation) preferredinterfaceorientationforpresentation
{
Return [self. viewcontrollers. firstobject preferredinterfaceorientationforpresentation];} 3. Construct the uinaviagitioncontroller subclass and write the following code in the Controller:-(bool) shouldautorotate
{
Return self. visibleviewcontroller. shouldautorotate;
}

-(Uiinterfaceorientationmask) supportedinterfaceorientations
{
Return [self. viewcontrollers. lastobject supportedinterfaceorientations];
}

-(Uiinterfaceorientation) preferredinterfaceorientationforpresentation
{
Return [self. viewcontrollers. lastobject preferredinterfaceorientationforpresentation];} 4. Write the following code on the uiviewcontroller page that allows redirection:-(bool) shouldautorotate
{
Return yes;
}

-(Uiinterfaceorientationmask) supportedinterfaceorientations
{
Return uiinterfaceorientationmaskall;} 5. Write the following code on the uiviewcontroller page that cannot be switched:-(bool) shouldautorotate
{
Return no;
}

-(Uiinterfaceorientationmask) supportedinterfaceorientations
{
Return uiinterfaceorientationmaskportrait;} Note: 1. the most important mistake here is to carefully enter the code inner in uitabbarcontroller. The difference is that the Code in uinaviagitioncontroller and uinavitioncontroller is self. viewcontrollers. firstobject; In uinaviagitioncontroller, self is returned. viewcontrollers. lastobject, and the permitted directions are also different: Self in uitabbarcontroller. viewcontrollers. firstobject. shouldautorotate; self in uinaviagitioncontroller. visibleviewcontroller. shouldaut Orotate; 2. since tagets is set for the entire project in the project, setting up, left, and right is equal to supporting the entire project, therefore, we should not only set shouldautorotate to no on the upper-level page returned from the horizontal screen, but also set it on every controller page in the project. I will simply write a page with viewdidload, we need to copy the two methods.

Projects only support portrait screens, and specific pages support landscape screens.

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.