iphone - 横向模式下的 UINavigationController 导航堆栈问题

标签 iphone ipad uinavigationcontroller uitabbarcontroller popviewcontroller

我有一个 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/

相关文章:

iphone - 在 super View 中开始触摸时接收 touchesMoved

objective-c - ipad - UISplitViewController 主拆分的奇怪行为

objective-c - 为什么popViewController Animated :YES occasionally not animate?

iphone - iOS 4 真的支持 ARC 吗? iOS 4.2 SDK 在链接时缺少与 ARC 相关的符号

iPhone - 加载新 View 和释放的对象

iphone - 点击tabBar时刷新tableView

iphone - 是否有建议的方法让 UITableView 开始在特定位置显示?

ios - 双击内部有 contenteditable 的 div 和 iframe 禁用 div

ios - 关于使用 UINavigationController 在 iOS 应用程序上扭曲后退按钮

iphone - 自定义以编程方式创建的导航栏的背景图像