In iOS4.2/iPhone4
Now I can see that my app delegate gets a message "applicationDidBecomeActive" when its selected after the last step, but how does my viewController (the one who's view is currently displayed) know?
viewDidLoad was already called, so that isn't called again. viewWillLoad is not called again.
Can't seem to figure it out. Reason I'm asking is I want to check to see if any Settings changes were made, but would like to do that in the view controller cause that's the thing that cares.
The answer is here: Handling applicationDidBecomeActive - "How can a view controller respond to the app becoming Active?"
Use NSNotificationCenter
to get notified of UIApplicationDidBecomeActiveNotification
events in your view controller.
in you're appDelegate applicationDidBecomeActive
put this :
- (void)applicationDidBecomeActive:(UIApplication *)application
{
UINavigationController *navc = (UINavigationController *)[tabBarController selectedViewController];
UIViewController *topvc = [navc topViewController];
if ([topvc respondsToSelector:@selector(viewControllerDidBecomeActive)])
{
[topvc performSelector:@selector(viewControllerDidBecomeActive)];
}
}
This gets the viewController that is being seen on screen. You just have to implement viewControllerDidBecomeActive
on every viewControllers ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With