我有一个 iPhone 应用程序,目前正在将其转换为 universal binary使用 iPad 进行工作。我已经成功实现了布局方面所需的一切,因此我的应用程序现在支持完整的横向功能(以前我主要使用纵向模式来显示内容)。
但是,我有一个奇怪的问题,它只发生在横向模式下:当我将 View Controller 插入堆栈时,需要点击后退按钮两次才能返回到上一个 View Controller !第一次点击会显示空白 View ,但左侧后退导航按钮上的名称相同,第二次点击会使 Controller 返回到上一个 View ,就像它应该的那样。
我没有 iPad 来测试,所以我依靠模拟器。该问题不会出现在 iPhone 上,并且如果您旋转回纵向模式也不会出现。
我的应用程序由一个 tabbarcontroller 和为其 vc 加载的导航 Controller 组成:
//application delegate
- (void)applicationDidFinishLaunching:(UIApplication *)application
//....
WebHelpViewController *vc8 = [[WebHelpViewController alloc] init];
UINavigationController *nv8 = [[UINavigationController alloc] initWithRootViewController:vc8];
[self.tabBarController setViewControllers:[NSArray arrayWithObjects:nv1,nv2,nv3,nv4,nv5,nv6,nv7,nv8,nil]];
为了实现横向功能,UITabBarController 被重写以在需要时自动旋转:
//CustomTabBarController.m
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return [[(UINavigationController *)self.selectedViewController topViewController] shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}
...工作正常。我使用此方法导航到新 View
SomeViewController *vc = [[SomeViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
[vc release];
这只是模拟错误吗?如何解决这个问题?
最佳答案
听起来像是另一个 ViewController
正在响应:
(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
首先检查一下。
关于iphone - 横向模式下的 UINavigationController 导航堆栈问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2694613/