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

发布于 2024-08-30 03:01:45 字数 1431 浏览 5 评论 0原文

我有一个 iPhone 应用程序,目前正在将其转换为通用二进制文件,以便在 iPad 上使用。我已经成功实现了布局方面所需的一切,因此我的应用程序现在支持完整的横向功能(以前我主要使用纵向模式来显示内容)。

但是,我有一个奇怪的问题,而且它只发生在横向模式下:当我将视图控制器推入堆栈时,需要轻按两次后退按钮才能返回到前一个视图控制器!第一次点击会显示空白视图,但左侧后退导航按钮上的名称相同,第二次点击会将控制器带回到上一个视图,就像它应该的那样。

我没有 iPad 来测试,所以我依靠模拟器。该问题不会出现在 iPhone 上,并且如果您旋转回纵向模式也不会出现。

我的应用程序由一个 tabbarcontroller 组成,其中为其 vc 加载了导航控制器:

//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];
}

...工作正常。我使用此方法导航到新视图

SomeViewController *vc = [[SomeViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
[vc release];

这只是一个模拟错误吗?我该如何解决这个问题?

I have an iPhone application that I am currently converting to a universal binary to work with the iPad. I have successfully implemented everything I need in terms of layout so that full landscape functionality is now supported in my app (previously I primarily used portrait mode to display content).

But, I have one strange problem, and it ONLY occurs in landscape mode: when I push a view controller onto the stack, it takes two taps on the back button to return to the previous view controller! The first tap shows a blank view, but with the same name on the left-side back navigation button, the second tap takes the controller back to previous view like it should.

I don't have an iPad to test, so I am relying on the simulator. The problem does not show up on the iPhone and doesn't show up if you rotate back to portrait mode.

My app consists of a tabbarcontroller with navigation controllers loaded for its vc's:

//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]];

To implement landscape capability, the UITabBarController is overridden to autorotate when required:

//CustomTabBarController.m
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return [[(UINavigationController *)self.selectedViewController topViewController] shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}

... works fine. I navigate into new views using this method

SomeViewController *vc = [[SomeViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
[vc release];

Is this only a simulation error? How do I fix this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

以酷 2024-09-06 03:01:45

听起来好像另一个 ViewController 正在响应:

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

先检查一下。

It sounds like another ViewController is responding to:

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

Check this first.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文