Lan Yi iOS iOS Development automatic rotation control code

Source: Internet
Author: User

Because the rotation will make the interface becomes discordant, unless you have developed a specific interface for a variety of directions, so sometimes it is better to disable rotation, or the program's interface is a horizontal screen, after exiting the horizontal screen view after the screen becomes vertical screen, such as watching video or browsing the Web when you want to be horizontal screen, But the rest of the work you want is a vertical screen. OK, none of this is a problem. We can control the rotation function of each interface in our program through code.

In the view controller you want to set up, find the Shouldautorotatetointerfaceorientation: method, overriding its implementation code:
 

    1. [Java]
    2. -(BOOL) Shouldautorotatetointerfaceorientation: (uiinterfaceorientation) interfaceorientation{
    3. return (interfaceorientation = = Uiinterfaceorientationlandscapeleft);
    4. }
Copy Code


The system asks this method to try to control whether to rotate to the specified direction. The system is defined in 4 directions, corresponding to 4 kinds of common holding modes:
 

  1. [Java]
  2. typedef enum {
  3. uiinterfaceorientationportrait = uideviceorientationportrait,
  4. Uiinterfaceorientationportraitupsidedown = Uideviceorientationportraitupsidedown,
  5. Uiinterfaceorientationlandscapeleft = Uideviceorientationlandscaperight,
  6. Uiinterfaceorientationlandscaperight = Uideviceorientationlandscapeleft
  7. } uiinterfaceorientation;
Copy Code


If you want to support rotation for any situation as long as you return yes, if you want to support only partially, return Yes to the supported return is not supported.

Lan Yi iOS iOS Development automatic rotation control code

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.