Control the orientation of sub-view rotation in iOS7

Source: Internet
Author: User

In order to allow the parent view (map view) to rotate at will, the Child view looks for some solutions based on a fixed direction (vertical screen) display, and finally finds that iOS7 is actually very simple.
-(BOOL)shouldAutorotate{    if([[UIDevice currentDevice] orientation] == UIInterfaceOrientationLandscapeLeft ||[[UIDevice currentDevice] orientation] == UIInterfaceOrientationLandscapeRight)    {        return NO;    }    else{        return YES;    }}
In addition, some users use the following method in iOS6:
Static CGSize appScreenSize; static UIInterfaceOrientation lastOrientation; + (CGSize) screenSize {UIInterfaceOrientation orientation = [UIApplication sharedApplication]. mismatch; if (appScreenSize. width = 0 | lastOrientation! = Orientation) {appScreenSize = CGSizeMake (0, 0); CGSize screenSize = [[UIScreen mainScreen] bounds]. size; // If the status bar is removed, you only need to use applicationFrame. If (orientation = UIDeviceOrientationLandscapeLeft | orientation = UIDeviceOrientationLandscapeRight) {// landscape screen, the returned width should be the height given by the system. Note: For full-screen applications and non-full-screen applications, you must increase or decrease the height of the status bar. AppScreenSize. width = screenSize. height; appScreenSize. height = screenSize. width;} else {appScreenSize. width = screenSize. width; appScreenSize. height = screenSize. height;} lastOrientation = orientation;} return appScreenSize ;}


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.