简体   繁体   English

单击按钮刷新/重新加载模态ViewController

[英]Refresh/Reload Modal ViewController on Button Click

How is it possible to refresh/reload a modal view controller on button click? 单击按钮时如何刷新/重新加载模态视图控制器? I need to reload an entire view controller . 我需要重新加载整个视图控制器。

You can dismiss your modal view controller and present it again setting the animation parameter to NO. 您可以关闭模​​态视图控制器,然后再次显示它,将animation参数设置为NO。 Another solution would be to embed your ViewController in a UINavigationController as its RootViewController (and present this one modally). 另一种解决方案是将ViewController作为RootViewController嵌入到UINavigationController中(并以模态形式呈现)。 When you have to reload your ViewController, simply use: 当您必须重新加载ViewController时,只需使用:

 - (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated

on the navigationController with an array containing a new instance of your ViewController. 在navigationController上,包含一个包含ViewController的新实例的数组。

Anyway, are you really sure you can't simply reset all the contents of your UIViewController without "reloading" it from scratch? 无论如何,您真的确定不能简单地重设UIViewController的所有内容而不从头开始“重载”它吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM