@property(nonatomic,readonly)UIDeviceOrientationorientation;// return current device orientation. this will return UIDeviceOrientationUnknown unless device orientation notifications are being generated.
typedefNS_ENUM(NSInteger,UIDeviceOrientation){UIDeviceOrientationUnknown,UIDeviceOrientationPortrait,// Device oriented vertically, home button on the bottomUIDeviceOrientationPortraitUpsideDown,// Device oriented vertically, home button on the topUIDeviceOrientationLandscapeLeft,// Device oriented horizontally, home button on the rightUIDeviceOrientationLandscapeRight,// Device oriented horizontally, home button on the leftUIDeviceOrientationFaceUp,// Device oriented flat, face upUIDeviceOrientationFaceDown// Device oriented flat, face down};
// Applications should use supportedInterfaceOrientations and/or shouldAutorotate..-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientationNS_DEPRECATED_IOS(2_0,6_0);
如果打算支持toInterfaceOrientation对应的方向就返回YES,否则返回NO。
2、iOS6中控制屏幕旋转相关方法:
12345
// New Autorotation support.-(BOOL)shouldAutorotateNS_AVAILABLE_IOS(6_0);-(NSUInteger)supportedInterfaceOrientationsNS_AVAILABLE_IOS(6_0);// Returns interface orientation masks.-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentationNS_AVAILABLE_IOS(6_0);
// call this method when your return value from shouldAutorotateToInterfaceOrientation: changes// if the current interface orientation does not match the current device orientation, a rotation may occur provided all relevant view controllers now return YES from shouldAutorotateToInterfaceOrientation:+(void)attemptRotationToDeviceOrientationNS_AVAILABLE_IOS(5_0);