我有 4 种不同的观点(a、b、c、d)。用户可以从:
a->b,
b->c ,b->d
c->b ,b->d
d-> c, d->b
要加载新视图,我使用 navitaion 控制器推送视图。
我的问题是,处理后退按钮的最佳解决方案是什么,以便使其始终像这样工作:
d->c
c->b
b->a
无论所有先前的视图控制器推送如何。
换句话说,用户进行以下转换序列:
(即a->b->c->b->c->d->c)但是当他按下后退按钮时我希望他看到屏幕B,而不是之前按下的D。
我知道如何以丑陋的方式解决它,但我期待更优雅的东西。
I have 4 different views (a,b,c,d). User can go from:
a->b,
b->c ,b->d
c->b ,b->d
d-> c, d->b
To load a new view I use navitaion controller push view.
My question what is the best solution to handle back button in order to make it always work like this:
d->c
c->b
b->a
regardless of all prior view controller pushes.
In the other words user makes the following sequence of transitions:
(ie.a->b->c->b->c->d->c) but when he presses back button I want him to see screen B, not previously pushed D.
I know how to solve it in ugly ways but I expect something more elegant.
发布评论
评论(1)
UINavigationController 支持通过 popToViewController:animated 方法弹回到特定的视图控制器...
官方 Apple 文档
不过,我建议重新考虑您的导航层次结构。 Apple 人机界面指南建议遵循结构化且一致的导航方案。在控制器之间跳转可能会让用户感到困惑。
UINavigationController supports popping back to a specific view controller through the popToViewController:animated method...
Official Apple Docs
I would however recommend rethinking your navigation hierarchy. The Apple Human Interface guidelines recommend following a structured and consistent navigation scheme. Jumping between controllers can be confusing for the user.