横屏设置
一、设置ViewControll
//支持旋转
- (BOOL)shouldAutorotate{
return NO;
}
//支持的方向
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
//一开始的方向
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
return UIInterfaceOrientationLandscapeRight;
}
二、自己维护横竖屏状态
建议写在viewWillAppear、viewWillDisappear里边
//进入页面时,将页面设置成横屏
[SupportedInterfaceOrientations sharedInstance].orientationMask = UIInterfaceOrientationMaskLandscape;
//退出页面时候,将页面设置成竖屏
[SupportedInterfaceOrientations sharedInstance].orientationMask = UIInterfaceOrientationMaskPortrait;
三、设置AppDelegate
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
//返回当前屏幕状态
return [SupportedInterfaceOrientations sharedInstance].orientationMask;
}