App delegate and View Controller in iOS4
With multi-tasking in iOS4, the home button puts the app into background and when it comes back into foreground I want the View Controller to 'refresh' (and hence viewWillAppear to be called). I put this in the app delegate thought this should work but nothing happens
- (void)ap开发者_Python百科plicationDidFinishLaunching:(UIApplication *)application {
//
[window addSubview:viewController.view];
[window makeKeyAndVisible];
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
[viewController.view reloadInputViews];
}
Can anyone help me with forcing a view controller to 'execute'/refresh when it is already showing?
You could call viewWillAppear explicitly e.g.
- (void)applicationWillEnterForeground:(UIApplication *)application {
[viewController.view reloadInputViews];
[viewController viewWillAppear];
}
精彩评论