自动向下钻取导航层次结构?

发布于 2024-10-05 06:20:59 字数 528 浏览 1 评论 0原文

我有一个基于导航的应用程序,允许用户向下钻取层次结构。一些子层次结构中只有一个元素,例如,

TopLevel1----->Level2a
TopLevel2   |->Level2b----->Level3a----->Level4a
            |->Level2c    

我只想从 Level2b 跳转到 Level4a,而不是让用户点击“Level3a”,但将 Level3a 视图保留在堆栈中,以便当用户回溯时,它是可见的。

我在这里找到了一些代码来模拟行点击:

模拟详细信息披露按钮按下

当加载每个级别时,我检查是否其中只有一个元素。如果是这样,我模拟行点击。这一切最初都有效,然后加载最终视图。但是当我开始回溯视图层次结构时,我遇到了问题(看起来跳过的视图未加载)。

我认为我想要完成的事情相当简单,所以我希望这里有人能指出我正确的方向。

I have a navigation-based app that allows the user to drill down through hierarchies. Some of the child hierarchies have only one element in them, e.g.,

TopLevel1----->Level2a
TopLevel2   |->Level2b----->Level3a----->Level4a
            |->Level2c    

Instead of making the user tap 'Level3a', I just want to jump from Level2b to Level4a, but keep the Level3a view in the stack so when the user backtracks, it is visible.

I found some code here to simulate a row tap:

Simulate a Detail Disclosure Button press

When each level is loaded, I check to see if there is only one element in it. If so, I simulate the row tap. This all works initially, and the final view is loaded. But when I start backtracking through the view hierarchy, I get problems (it appears that the skipped views aren't loaded).

I think what I'm trying to accomplish is fairly simple, so I'm hoping someone on here can point me in the right direction.

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

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

发布评论

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

评论(2

逆光下的微笑 2024-10-12 06:21:22

我不是 100% 确定这会起作用,但这就是我会做的。

您可以直接 [self.navigationController PushViewController:level4aanimated:NO] ,完成后,设置一个新的 viewControllers 数组,即 navigationController 属性(包含 Level3a 的数组)。

这是一个代码示例,位于 didSelectRowAtIndexPath:

[self.navigationController pushViewController:level4a animated:NO]; //Push the level 4 first
NSMutableArray* mutableViewControllers = [self.navigationController.viewControllers mutableCopy];
[mutableViewController addObject:level3a atIndex:3]; //Add the level 3 manually
self.navigationController.viewControllers = mutableViewControllers;
[mutableViewControllers release];

I'm not 100% sure that would work, but that's what I would do.

You could directly [self.navigationController pushViewController:level4a animated:NO] and when that's done, set a new array of viewControllers, the navigationController propriety (an array that includes Level3a).

Here is a code sample, in you didSelectRowAtIndexPath:

[self.navigationController pushViewController:level4a animated:NO]; //Push the level 4 first
NSMutableArray* mutableViewControllers = [self.navigationController.viewControllers mutableCopy];
[mutableViewController addObject:level3a atIndex:3]; //Add the level 3 manually
self.navigationController.viewControllers = mutableViewControllers;
[mutableViewControllers release];
少年亿悲伤 2024-10-12 06:21:18

您应该能够在 level3 视图控制器的 viewWillAppear 方法中放置 [self.navigationController PushViewController:level4animated:NO] 调用。这会自动将 level4 推到 level3 之上。

如果它只在某些时候发生,level3 可以有一个属性来指示此行为何时发生。

You should be able to place a [self.navigationController pushViewController:level4 animated:NO] call in the viewWillAppear method for your level3 view controller. This will automatically push level4 on top of level3.

If it only happens some of the time, level3 can have a property to indicate when this behavior takes place.

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