有没有办法在 poptorootviewcontroller
上强制执行 viewdidload
?
我有一个应用程序,我在 appdelegate
中创建了一个 NavigationController
,在 RootViewController
中有一个动画通过 locationdidupdate
delegate 方法,很多请求到服务器然后,它推送另一个 viewcontroller
然后应用程序正常工作。
问题是在应用程序期间可能有 poptorootviewcontroller
的可能性,但如果我这样做,它不会启动任何东西,从动画开始并继续请求,所以该应用无法正常运行。
我的问题是:
如何通过命令poptorootviewcontroller
强制viewdidload
?
我尝试使用 viewwillappear
,但流程无法正常工作。
有什么建议吗?
谢谢!
最佳答案
使用通知中心
。丑陋的方式,但必须完成任务:)
当你想让 viewdidload 再次加载时,把这个放在...
[[NSNotificationCenter defaultCenter] postNotificationName:@"ContactListDisappeared" object:self];
在viewWillAppear或viewDidAppear中,有
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doTheTaskHere:) name:@"ContactListDisappeared" object:nil];
为此设置操作...
- (void)doTheTaskHere:(NSNotification *)notification {
// call view did load again...
[self viewDidLoad];
}
希望这就是你想要的。
只有今天,我想要这样的东西,我以这种方式实现了。
关于iphone - 在 Poptorootviewcontroller 上强制 Viewdidload,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19497687/