自动向下钻取导航层次结构?
我有一个基于导航的应用程序,允许用户向下钻取层次结构。一些子层次结构中只有一个元素,例如,
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不是 100% 确定这会起作用,但这就是我会做的。
您可以直接
[self.navigationController PushViewController:level4aanimated:NO]
,完成后,设置一个新的viewControllers
数组,即navigationController
属性(包含Level3a
的数组)。这是一个代码示例,位于
didSelectRowAtIndexPath:
中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 ofviewControllers
, thenavigationController
propriety (an array that includesLevel3a
).Here is a code sample, in you
didSelectRowAtIndexPath:
您应该能够在 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 theviewWillAppear
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.