- (BOOL)shouldAutorotate {
//返回是否允许转屏
return YES;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations{
//返回所支持的旋转方向
return UIInterfaceOrientationMaskPortrait|UIInterfaceOrientationMaskLandscapeLeft;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
//返回初始化显示的方向
return UIInterfaceOrientationMaskLandscapeLeft;
}
注册通知监听屏幕旋转方法名:UIApplicationDidChangeStatusBarOrientationNotification
获取当前屏幕方向:UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if(orientation == UIInterfaceOrientationLandscapeLeft){}
else if (orientation == UIInterfaceOrientationLandscapeRight) {}
网友评论