Any class in your application can become an "observer" for different notifications in the application. When you create (or load) your view controller, you'll want to register it as an observer for the UIApplicationDidBecomeActiveNotification
and specify which method that you want to call when that notification gets sent to your application.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(someMethod:)
name:UIApplicationDidBecomeActiveNotification object:nil];
Don't forget to clean up after yourself! Remember to remove yourself as the observer when your view is going away:
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIApplicationDidBecomeActiveNotification
object:nil];
More information about the Notification Center.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…