I have a UIViewController on a tab of a tab based app, that hooks up UIApplicationDelegate. I'd like to handle app events by UIApplicationDelegate, but I don't get them in my UIViewController, its methods are not called.
What should I do beside hook up it in my UIViewController's interface declaration?
@interface TestViewController : UIViewController<UIApplicationDelegate>
@end
Other delegates are works, I can handle them, except this, UIApplication and its delegate should have some trivial 'trick', but I could not find.
Thanks!
If you need a class other than the app delegate to respond to the various application events, then have the other class register for the various application notifications.
For example, to deal with the app entering the background:
// Put this in the class that needs to deal with entering the background
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(backgrounding) name:UIApplicationDidEnterBackgroundNotification object:nil];
See the docs for UIApplication
for a list of all of the notifications.
Don't forget to remove the observer in the dealloc
method of the class.
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