开发者

What method is called when application appears from background on iPhone?

开发者 https://www.devze.com 2023-01-17 08:12 出处:网络
I know that when iphone application goes to background, these methods are called: - (void)applicationDidEnterBackground:(UIApplication *)application

I know that when iphone application goes to background, these methods are called:

- (void)applicationDidEnterBackground:(UIApplication *)application
- (void)applicationWillResignAct开发者_JAVA百科ive:(UIApplication *)application

what method(s) are called when application appears from background?

are there any methods in ViewController which are called?

thanks


Along with the applicationDidBecomeActive: and applicationWillEnterForeground: messages sent to the application delegate, the OS will also send corresponding UIApplicationDidBecomeActiveNotification and UIApplicationWillEnterForegroundNotification notifications.

You can have your view controller listen to these notifications:

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(appWillEnterForegroundNotification:) 
                                             name:UIApplicationWillEnterForegroundNotification 
                                           object:nil];

Don't forget to remove yourself as an observer before your view controller gets destroyed.


– applicationDidBecomeActive:
– applicationWillEnterForeground:

Oops didnt read your question properly. These two methods are in the UIApplicationDelegate

– viewWillAppear:
– viewDidAppear:

And those are in UIViewController

0

精彩评论

暂无评论...
验证码 换一张
取 消