ios 如何关闭使用 presentModalViewController 打开的视图控制器:
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5156791/
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
How to dismiss a view controller opened with presentModalViewController:
提问by WangYang
I presented a view controller using presentModalViewController:
, now how to close/dismiss it?
我使用 展示了一个视图控制器presentModalViewController:
,现在如何关闭/关闭它?
采纳答案by machunter
You have two choices, both involves using dismissModalViewController.
您有两种选择,都涉及使用dismissModalViewController。
The preferred way is to use delegation and tell the view controller who was responsible for presenting the view to dismiss it. The other way is to have the view who was presented to dismiss itself (which actually asks the parent to dismiss it.)
首选的方法是使用委托并告诉负责呈现视图的视图控制器关闭它。另一种方法是让被呈现的视图自行驳回(实际上要求父母驳回它。)
回答by Nithinbemitk
For iOS6 use this code
对于 iOS6 使用此代码
[self dismissViewControllerAnimated:YES completion:Nil];
instead of
代替
[self dismissModalViewControllerAnimated:YES];
This may help you.
这可能对你有帮助。
回答by r36363
From the controller presented modally:
从以模态呈现的控制器中:
[self dismissModalViewControllerAnimated:YES]