【发布时间】:2011-09-29 22:15:21
【问题描述】:
我很难让导航控制器正确自动旋转。显示将在初始视图(根视图控制器)上自动旋转,但不会在任何被推送的新视图上旋转。它保持初始视图在推送时的视图方向。
在我的 App Delegate 中,我有一个导航控制器并推送它的视图。
[window addSubview:navigationController.view];
[window makeKeyAndVisible];
在根视图控制器中,我允许所有方向,并将其他视图推送到控制器的堆栈中。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
ParkingListController *parklc = [[ParkingListController alloc] autorelease];
[[self navigationController] pushViewController:parklc animated:YES];
我看到“是的,我们应该!”在新视图加载时记录一次,但在设备实际旋转时不会触发。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
NSLog(@"Yes, we should!");
return YES;
}
我没有任何初始化覆盖,并且 info.plist 列出了所有四个方向。
我错过了什么?谢谢!
编辑 2011-07-07:
奇怪的是,当您从表格视图中选择一个项目时,地图视图会自动旋转!为什么它来自的table view不能旋转?
【问题讨论】:
-
快速提问:这个 rootViewController 是否在标签栏中使用?如果是这样,您是否对标签栏进行了子类化并在 shouldautorotate 中返回 YES?
-
@bart:你找到解决方案了吗?我也有类似的问题。
标签: iphone ios ipad uiviewcontroller