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!