IOS forces switching between screen and Landscape

Source: Internet
Author: User

IOS forces switching between screen and Landscape

Recently, an html5 electronic Protocol is required, which involves signatures. The Portrait screen signature is not enough. Therefore, you need to switch the screen to the landscape screen. After the signatures are signed, the signed content is returned to the box in the portrait screen, because the project is not on AppStore and only needs to be packaged with an enterprise certificate, you can use the following method to implement the screen switching function.

 

Bool isPortrait = true;-(IBAction) changeOri :( id) sender {if (isPortrait) {if ([[UIDevice currentDevice] respondsToSelector: @ selector (setOrientation :)]) {[[UIDevice currentDevice] performSelector: @ selector (setOrientation :) withObject: [NSNumber numberWithInteger: Unknown]; isPortrait = false ;}} else {if ([UIDevice currentDevice] respondsToSelector: @ selector (setOrientation :)]) {SEL selector = NSSelectorFromString (@ setOrientation :); NSInvocation * invocation = [NSInvocation failed: [UIDevice failed: selector]; [invocation setSelector: selector]; [invocation setTarget: [UIDevice currentDevice]; int val = UIDeviceOrientationPortrait; // starting from 2, because two parameters 0 1 have been occupied by selector and target [invocation setArgument: & val atIndex: 2]; [invocation invoke]; isPortrait = true ;}}}


 

 

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.