当旋转iPhone时,每个选项卡中的每个控制器都会自动进入横向模式。
即使在每个控制器中覆盖shouldAutorotateToInterfaceOrientation并返回NO也无效:当旋转iPhone时,控制器仍会进入横向模式。
我在子类化的UITabBarController中实现了shouldAutorotateToInterfaceOrientation如下:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if([self selectedIndex] == 0 || [self selectedIndex] == 3)
return YES;
return NO;
}
我希望只有我感兴趣的两个选项卡能够支持横屏模式。是否有一种方法可以为特定选项卡堆栈上的特定控制器支持横屏模式?
我尝试过以下操作,但没有成功:
(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if([self selectedIndex] == 0 || [self selectedIndex] == 3)
{
if ([[self selectedViewController] isKindOfClass: [landscapeModeViewController class]])
return YES;
}
return NO;
此外,我尝试使用委托方法didSelectViewController,但没有成功。非常感谢您的帮助。谢谢。