1

我有一个连接到多个视图控制器的地图视图。

我需要从另一个按钮(而不仅仅是后退按钮)实现“展开”,所以我使用了:

self.navigationController?.popViewControllerAnimated(true)

我的问题是:由于上述工作,我是否应该费心尝试在代码中使用父视图控制器prepareForUnwindcanPerformUnwindSegueActionctrl-drag 从 viewController 中实现展开以退出 Storyboard?如果是这样,为什么?

4

1 回答 1

4

基本上,如果您只是从导航堆栈中dimissing呈现UIViewController或弹出一个UIViewController,则不需要使用 unwind segues,尽管它对您也是如此。

但是想想有UINavigationControllers A,B,C然后是RootViewController R的情况

然后想一个条件

 (Present) R -> A
 (Push) AR -> XVController
 (Push)XVController -> B
 (Present)BR-> YVContoller
...and so on..

现在,如果你想回到 YVController 到你刚刚启动的项目 RootViewController。没有办法popToRootViewController弹出到 B 的导航堆栈UINavigationController。现在你做什么..使用委托或更改窗口 RootViewController这不是好主意

所以你需要使用 unwind segue 来克服这个问题。一个示例项目来展示使用它的强大功能。

于 2016-02-10T15:52:09.707 回答