2016-02-09 63 views
1

我有一个连接到几个viewControllers的mapview。unwind segue vs. popViewControllerAnimated

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

self.navigationController?.popViewControllerAnimated(true) 

我的问题是:作为上述作品,应我甚至懒得尝试在父视图控制器中使用prepareForUnwindcanPerformUnwindSegueAction代码展开代码展开+从控制器中按住Ctrl键拖动以在故事板中退出?如果是这样,为什么?

回答

3

基本上,如果您只是dimissing呈现UIViewController或从导航堆栈弹出UIViewController,您不需要使用展开segues,虽然它也为您执行相同操作。

不过想到的情况,其中有UINavigationControllersA,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来克服这个..一个样本project来演示使用它的能力..

相关问题