NavigationController 返回跳过视图 [英] NavigationController Back Skip View
问题描述
首先,我知道这个问题是以向前的方式提出的,但在这种情况下,我要求以一种向后的方式来设计导航控制器.话虽如此……
First off, I am aware of this question being asked in a forward manner, but in this case I am asking for a backwards manner in which the Navigation Controller is already designed. With that being said...
我有一个带有三个视图的 UINavigationController
:Table
、Get
和 Avail
在 IB 中创建.
I have a UINavigationController
with three views: Table
, Get
, and Avail
in that order that was created in IB.
前进时,我想从 Table
到 Get
再到 Avail
,但是当我点击 Table
上的Back"按钮时code>Avail 我想跳过Get
,直接回到Table
.这可能吗?如果是这样,如何?
When going forward, I want to go from Table
to Get
to Avail
, but when I hit the "Back" button on Avail
I want to skip over Get
and go directly back to Table
. Is this possible? If so, how?
推荐答案
我是这样做的:
NSArray *VCs = [self.navigationController viewControllers];
[self.navigationController popToViewController:[VCs objectAtIndex:([VCs count] - 2)] animated:YES];
为了能够覆盖导航控制器的后退按钮,您必须继承 UINavigationController.查看本教程中的操作方法:http://www.hanspinckaers.com/custom-action-on-back-button-uinavigationcontroller
To be able to override the nav controllers's back button you're going to have to subclass UINavigationController. Check out how in this tutorial: http://www.hanspinckaers.com/custom-action-on-back-button-uinavigationcontroller
这篇关于NavigationController 返回跳过视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!