1、app有多个页面,但是只允许一个页面旋转,其余不允许旋转的页面添加如下代码:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return NO;
}
- (BOOL)shouldAutorotate
{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
允许旋转的页面添加如下代码:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return (toInterfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
2、页面之间采用UINavigationController切换(push、pop)
self.window.rootViewController = _navigationController;
3、假设现在有3个页面,第2个页面允许旋转,1、3页面不允许旋转。
4、进行如下操作:
竖屏状态到2页面(portrait)
-> 将2页面旋转为横屏(landscape)
-> pop回1页面 或者 push到3页面
-> 神奇的事发生了,1、3页面本来是不允许横屏的,但是现在都变成了横屏,而这些页面都未做横屏适配,所以看起来很丑。
请教各路大神:从横屏的2页面到1、3页面时,怎么让1、3页面不旋转为横屏,保持进入2页面时的竖屏状态?
谢谢!!!!!
PS:这个问题我纠结2个月了,实在找不到合适的解决办法,调试发现:1、3页面的frame是在2页面调用pop或者push之后被改变的