导航控制器的问题

发布于 2024-12-29 10:36:13 字数 833 浏览 1 评论 0原文

我正在展示一个导航控制器,其中的视图控制器使用 presentModalViewController 初始化为其根。但是,当我将另一个视图控制器推送到这个新的导航堆栈上时,需要按后退按钮两次才能返回到以模式方式呈现的原始视图。知道为什么会发生这种情况吗?新的视图控制器是否有可能被推送到原始导航控制器上,然后也被推送到模态视图控制器中的导航控制器上?

我在原始导航控制器中的代码:

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:addViewController];  
[self.navigationController presentModalViewController:navController animated:YES];
[addViewController release];
[navController release];

然后是我在模态视图中的代码:

PriorityViewController *priorityView = [[PriorityViewController alloc] initWithNibName:@"PriorityView" bundle:nil];
priorityView.taskInfo = self.taskInfo;
priorityView.isAdding = YES;
[self.navigationController pushViewController:priorityView animated:YES];
[priorityView release];

I am presenting a navigation controller with a view controller initialized as its root using presentModalViewController. However, when I push another view controller onto this new navigation stack, the back button needs to be pushed twice to return to the original view presented modally. Any idea why this would occur? Is it possible that the new view controller is being pushed onto the original navigation controller and then the navigation controller in the modal view controller as well?

My code in the original navigation controller:

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:addViewController];  
[self.navigationController presentModalViewController:navController animated:YES];
[addViewController release];
[navController release];

And then my code inside the modal view:

PriorityViewController *priorityView = [[PriorityViewController alloc] initWithNibName:@"PriorityView" bundle:nil];
priorityView.taskInfo = self.taskInfo;
priorityView.isAdding = YES;
[self.navigationController pushViewController:priorityView animated:YES];
[priorityView release];

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

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

发布评论

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

评论(2

月牙弯弯 2025-01-05 10:36:13

您有两个导航堆栈 - 您正在以模态方式呈现一个导航控制器

只需使用一个,如下所示:

 [self.navigationController presentModalViewController:addViewController animated:YES];
 [addViewController release];

You have two navigation stacks - you are presenting a navigation controller modally.

Just use one, like this:

 [self.navigationController presentModalViewController:addViewController animated:YES];
 [addViewController release];
给我一枪 2025-01-05 10:36:13

我弄清楚了我的问题。我正在处理视图控制器和导航控制器。但正在使用表视图将新控制器推送到导航控制器堆栈上。并且在我的表视图中处理行选择的 switch 语句缺少一个 break 语句,因此调用了两个案例,而不是仅针对该行的一个案例(如果这有意义的话)。

I figured out my issue. I was handling the view controllers, and the navigation controller just fine. But was using a table view to push the new controllers onto the navigation controller stack. And the switch statement handling the row selection in my table view was missing a break statement, so two cases were being called instead of just one meant for that row, if that makes any sense.

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