UINavigationController 的问题

发布于 2024-11-25 13:55:47 字数 550 浏览 2 评论 0原文

我在我的应用程序中使用 UINavigationController。当“返回”时,我想跳过一个视图。我目前正在做的是这样的:

在我不想看到的视图的 viewDidAppear 中,我检查它是否是通过后退按钮单击出现的,如果是的话,我会调用:

[self.navigationController popViewControllerAnimated:YES];

但是会发生这样的情况:

不需要的视图和前一个视图变成一个视图(一个视图位于另一个视图之上)。

更多解释:

不需要的视图是第二个视图,我想转到根视图: 我使用的另一个代码是:

[self.navigationController popToRootViewControllerAnimation:YES]

这种方法的问题是 2: a) 我仍然在导航栏中看到一个我不应该看到的后退按钮 b) 应该有的工具栏项目不存在。 (不过,工具栏本身就在那里!)

任何人都可以让我知道我在这里做错了什么吗?谢谢。

I am using UINavigationController in my app. While going "Back" I want to skip one view. What I am currently doing is this :

In the viewDidAppear of the view I don't want to see I check to see if it appeared from a back button click, if so I call :

[self.navigationController popViewControllerAnimated:YES];

But what happens is this:

the unwanted view and the previous view get morphed into one view (one on top of the other).

more explanation:

the unwanted view is the 2nd view and I want to go to the rootview:
Another code that I used was:

[self.navigationController popToRootViewControllerAnimation:YES]

The problem with this approach is 2:
a) I still get a back button in the navigation bar that I should not be getting
b) The toolbar items that should be there are not there. (the toolbar itself is there, though!)

Can anyone kindly let me know what I did wrong here ? Thanks.

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

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

发布评论

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

评论(2

不喜欢何必死缠烂打 2024-12-02 13:55:47

您可以尝试以下操作:

int count = [self.navigationController.viewControllers count];
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:count-2]]

请记住 count 是一个从 0 开始的数组,因此只需执行 count - x 即可,同时考虑到这一点。

我也很确定这会起作用,但看起来不干净:

UINavigationController *navController = self.navigationController;

[navController popViewControllerAnimated:NO];
[navController popViewControllerAnimated:YES];

希望有帮助。

You can try this:

int count = [self.navigationController.viewControllers count];
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:count-2]]

Keep in mind the count is an array starting at 0 so just do count - x, taking that into consideration.

Also I am pretty sure this would work but it doesn't look clean:

UINavigationController *navController = self.navigationController;

[navController popViewControllerAnimated:NO];
[navController popViewControllerAnimated:YES];

Hope that helps.

你又不是我 2024-12-02 13:55:47

为了解决这个问题,我需要做的是::

从第三个视图和操作处理程序 popToRootViewController 中自定义后退按钮功能,

谢谢。

What I needed to do in order to sovle this problem was this ::

Customize the backbutton function from the 3rd view and in the action handler popToRootViewController

Thanks.

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