问题描述:在自带UITabBarController和UINavigationController的情况下,部分界面强制横屏,其他界面竖屏。
在【手机竖排方向锁定】关闭的情况下,控制单个不随着陀螺仪方向旋转,即成为所谓的“死界面”
解决方法:
1.自定义UITabBarController_autoRotate继承自UITabBarController,UITabBarController_autoRotate.m文件里添加下列方法
- (BOOL)shouldAutorotate
{
return [self.selectedViewController shouldAutorotate];
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return [self.selectedViewController supportedInterfaceOrientations];
}
2.自定义UINavigationController_autoRotate继承自UINavigationController,UINavigationController_autoRotate.m文件里添加下列方法
- (BOOL)shouldAutorotate
{
return [self.visibleViewController shouldAutorotate];
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return [self.visibleViewController supportedInterfaceOrientations];
}
3.A类控制界面要求横屏,A.m文件里添加下列方法
- (BOOL)shouldAutorotate
{
return NO;
}
// 禁止横屏
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
4.B类控制界面要求竖屏,B.m文件里添加下列方法
- (BOOL)shouldAutorotate
{
return YES;
}
// 禁止横屏
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}