Interface orientation for Cocos2D-iphone Development)

Source: Internet
Author: User

Briefly record an application screen direction problem today.

Generally, the application specifies a direction, such as landscape or portrait ).

So how to set it?

Note: different versions must be distinguished here.

Find the appdelegate. M file

// The available orientations shocould be defined in the info. plist file. the supported direction must be in info. the plist file defines // and in iOS 6 + only, you can override it in the Root View Controller in the "supportedinterfaceorientations" method. // only valid for iOS 6 +. not valid for iOS 4/5. -(nsuinteger) supportedinterfaceorientations {// It is specified to be vertical here, including two regions and zones // iPhone onlyif ([[uidevice currentdevice] userinterfaceidiom] = uiuserinterfaceidiomphone) return messages | links; // iPad only return uiinterfaceorientationmaskportrait | uiinterfaceorientationmaskportraitupsidedown;} // supported orientations. customize it for your own needs // only valid on iOS 4/5. not valid for iOS 6. -(bool) orientation :( uiinterfaceorientation) interfaceorientation {// The vertical orientation is also specified here // iPhone onlyif ([[uidevice currentdevice] userinterfaceidiom] = uiuserinterfaceidiomphone) return orientation (interfaceorientation ); // iPad only return uiinterfaceorientationisportrait (interfaceorientation); // This method specifies horizontal // return uiinterfaceorientationislandscape (interfaceorientation );}

The code above shows that the first method is used to set the ios6 + version, and the second method is to set the ios4/5 version.

For uiinterfaceorientationmask In the first method, select return as needed.

typedef enum {   UIInterfaceOrientationMaskPortrait = (1 << UIInterfaceOrientationPortrait),   UIInterfaceOrientationMaskLandscapeLeft = (1 << UIInterfaceOrientationLandscapeLeft),   UIInterfaceOrientationMaskLandscapeRight = (1 << UIInterfaceOrientationLandscapeRight),   UIInterfaceOrientationMaskPortraitUpsideDown = (1 << UIInterfaceOrientationPortraitUpsideDown),   UIInterfaceOrientationMaskLandscape =   (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight),   UIInterfaceOrientationMaskAll =   (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft |   UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown),   UIInterfaceOrientationMaskAllButUpsideDown =   (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft |   UIInterfaceOrientationMaskLandscapeRight),} UIInterfaceOrientationMask;

This is probably the case!


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.