Unwind segue function with Back button

时间秒杀一切 提交于 2019-12-03 11:21:59
YichenBman

You can use a delegate method to accomplish what you are doing.

Here is a really thought out swift tutorial that deal with delegates and segues: http://makeapppie.com/2014/07/05/using-delegates-and-segues-part-2-the-pizza-demo-app/

What you are asking, ability to catch the back button's action, isn't possible the way you describe it.

Most people would recommend creating a custom button, then use an unwind segue.

There are lots of tutorials on custom back buttons just in case you're new to swift, and the ugly part of the custom back button can be easily fixed by putting your own arrow there.

Also I found this previous asked question for future reference: Unwind segue from navigation back button in Swift

Actually I just assigned the unwind segue to the entire view controller (right click from the yellow view controller outlet and drag to the exit outlet then select the function). And it works great so far. No need custom button, no delegate. In fact, in my project the child is supposed to call the different parent's function according to current caller view controller and simply using the same function name made my dreams come true.

This page helped me a lot: http://spin.atomicobject.com/2014/12/01/program-ios-unwind-segue/

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!