xcode 以编程方式,如何使用推送转场让应用程序在首先到达屏幕时返回到之前的视图
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11092184/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Programmatically, how to make an app return to previous view when it got to the screen in the first place using a push segue
提问by Sam Gehly
I am creating an app where if it cannot load a webpage, it displays an error and returns to the previous screen. I am having difficulty getting it to return to the previous screen.
我正在创建一个应用程序,如果它无法加载网页,则会显示错误并返回上一个屏幕。我很难让它返回上一个屏幕。
I am using a push segue to have it go to the screen in the first place.
我首先使用 push segue 让它进入屏幕。
Thank you for your help.
感谢您的帮助。
回答by Chris Trahey
A push segue requires a navigation controller, and with a navigation controller you can use popViewControllerAnimated:
push segue 需要一个导航控制器,并且通过导航控制器你可以使用 popViewControllerAnimated:
[self.navigationController popViewControllerAnimated:YES];
Though many would advocate using delegation for something like this (perhaps even with modal instead of navigation controller).
尽管许多人会提倡使用委托来处理这样的事情(甚至可能使用模式而不是导航控制器)。