1、先上代码:
- (UIInterfaceOrientationMask)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAll;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
return NO;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
return UIInterfaceOrientationLandscapeRight;
}
再次运行,完全旋转!
PS: 此种方法只针对present过来的界面有效,而对于push过来的是无效的。
2、获取设备的屏幕方向:
if (![UIDevice currentDevice].generatesDeviceOrientationNotifications) {
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
}
NSLog(@"%d",[UIDevice currentDevice].orientation);
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];