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.
我不想让用户点击“Level3a”,而只是想从Level2b跳到Level4a,但是将Level3a视图保留在堆栈中,这样当用户回溯时,它就是可见的。
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.
我认为我想要完成的事情相当简单,所以我希望有人能指出我正确的方向。
2 个解决方案
#1
0
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.
您应该能够在level3视图控制器的viewWillAppear方法中放置[self.navigationController pushViewController:level4 animated:NO]调用。这将自动将level4推到level3之上。
If it only happens some of the time, level3 can have a property to indicate when this behavior takes place.
如果它只在某些时候发生,则level3可以有一个属性来指示何时发生此行为。
#2
0
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
).
您可以直接[self.navigationController pushViewController:level4a animated:NO],当完成后,设置一个新的viewControllers数组,即navigationController propriety(包含Level3a的数组)。
Here is a code sample, in you didSelectRowAtIndexPath:
这是一个代码示例,在你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];
#1
0
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.
您应该能够在level3视图控制器的viewWillAppear方法中放置[self.navigationController pushViewController:level4 animated:NO]调用。这将自动将level4推到level3之上。
If it only happens some of the time, level3 can have a property to indicate when this behavior takes place.
如果它只在某些时候发生,则level3可以有一个属性来指示何时发生此行为。
#2
0
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
).
您可以直接[self.navigationController pushViewController:level4a animated:NO],当完成后,设置一个新的viewControllers数组,即navigationController propriety(包含Level3a的数组)。
Here is a code sample, in you didSelectRowAtIndexPath:
这是一个代码示例,在你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];