Perform the function of bringing the application from sleep

Hey guys, I'm sure this is something very direct, but I can’t find the information anywhere. I need my application to reload some information when it opens from the background (and not fresh open). Any ideas how to do this?

thank

+3
source share
2 answers

Your application can override - (void)applicationWillEnterForeground:(UIApplication *)applicationin yours UIApplicationDelegate.

You also have your controller, which will become an observer for the UIApplicationWillEnterForegroundNotification . According to Apple Docs: published shortly before the application leaves the background state on its way to becoming an active application.

NIB, - (id)init:

- (void)awakeFromNib {
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wakeUp:) name:UIApplicationWillEnterForegroundNotification object:nil];
}

- (void)wakeUp:(NSNotification *)pNotification {
    NSLog(@"Name: %@", [pNotification name]);
    NSLog(@"Object: %@", [pNotification object]);
    NSLog(@"I am waking up");
}

- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [super dealloc];
}
+5
+4

All Articles