为了保证每次APP启动必然竖屏,在工程配置中Device Orientation必须只选择Protrait。这个时候你会发现每个界面都无法旋转了,需要在AppDelegate中加入如下代码(具体支持的方向可以自行选择):
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
需要支持旋转的页面可以在ViewController中去实现(如果是导航栏push或者Tabbar控制器的子VC,需要到根控制器实现这些方法):
//是否支持自动旋转
-(BOOL)shouldAutorotate {
return YES;
}
//支持自动旋转的方向
-(UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAllButUpsideDown;
}