iOS manual control on, disable screen rotation

Source: Internet
Author: User

Recently in the company to do the ipad development, unlike most iphone applications, the ipad program requires support for the screen, but sometimes some pages do not need screen rotation, Internet search a lot of data found are not available or meet the requirements. First, the following methods are rewritten directly in the Uiviewcontroller, and the discovery is not performed.

- (BOOL) shouldautorotate; - (Nsuinteger) supportedinterfaceorientations; -(uiinterfaceorientation) preferredinterfaceorientationforpresentation;

Best, find the solution, first create a new category of Uinavigatetion, and then rewrite the method inside

-(BOOL) shouldautorotate {// support auto-rotation    return  [[Self.viewcontrollers Lastobject] Shouldautorotate];} -(Nsuinteger) supportedinterfaceorientations {// device Support direction    return  [[ Self.viewcontrollers Lastobject] supportedinterfaceorientations];} -(Uiinterfaceorientation) preferredinterfaceorientationforpresentation {// Direction identification     return  [[Self.viewcontrollers Lastobject] preferredinterfaceorientationforpresentation];}

Then, in your uiviewcontroller to implement the above several methods, you can control the direction of the screen with your heart.

iOS manual control on, disable screen rotation

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.