Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

So I want to support app switching in my upcoming iPhone app and I've implemented all the proper delegate methods in my application delegate. So when the user resumes the application, I can see their activity in the NSLog and all. However, how can I tell my app has resumed a controller? Is there a method I can put in my controller to tell me the app has resumed in said controller? Reason I ask is because my application handles its own URL schema, and I want to update the view depending on the URL launched. Any help will be greatly appreciated.

Thanks in advance

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
345 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can have you your controller observe the UIApplicationWillEnterForeground notification. It probably would look something like this:

- (void) viewDidLoad
{
    [super viewDidLoad];
    //do stuff here
    if(&UIApplicationWillEnterForegroundNotification) { //needed to run on older devices, otherwise you'll get EXC_BAD_ACCESS
        NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
        [notificationCenter addObserver:self selector:@selector(enteredForeground:) name:UIApplicationWillEnterForegroundNotification object:nil];
    }


}
- (void)enteredForeground:(NSNotification*) not
{
    //do stuff here
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...