1
我有2个视图控制器,根和细节。根视图控制器支持横向和纵向,因此它具有以下代码:pushViewController: - 当设备处于横向模式时,如何以纵向模式显示?
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait
|| interfaceOrientation == UIInterfaceOrientationLandscapeLeft
|| interfaceOrientation == UIInterfaceOrientationLandscapeRight
|| interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
}
上述代码完美适用于根视图控制器。
如果正在显示根视图控制器,并且用户将设备旋转到横向模式,则视图会相应地进行调整。从这一点来看,如果将我的详细视图控制器推到堆栈上,它将以横向模式加载。但是,它不应该,因为我已将它配置为仅支持肖像模式。我使用下面的代码在我的详细视图控制器:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
这只是结束了运行相同代码的宏我已经有了。然而,只是为了好玩,我试过了...而且我收到了相同的结果。我的第二个视图加载在横向模式下,而不是纵向... – bpatrick100 2011-02-16 17:17:19