开发者

Application event when screen becomes active

开发者 https://www.devze.com 2023-03-20 03:12 出处:网络
I have a NSTimer that I create when entering method - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions.

I have a NSTimer that I create when entering method - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions.

When entering method - (void)applicationDidEnterBackground:(UIApplication *)application I say [timer i开发者_JAVA百科nvalidate]; timer = nil;

When entering method - (void)applicationWillEnterForeground:(UIApplication *)application I create the timer again. This works when the user has pressed the home button and then runs the application again. However if my screen gets inactive because of user inactivity when inside the app, then becomes active and then automatically enters the application again, the timer will not work. Therefore I am wondering what method is accessed when the application re-enters from an inactive screen.

Thank you


You can use the applicationDidBecomeActive: method instead of applicationWillEnterForeground:.


Tried these?

- (void)applicationDidBecomeActive:(UIApplication *)application;
- (void)applicationWillResignActive:(UIApplication *)application;

The other case you may want to investigate is when a phone call comes in (or an SMS message alert is presented).

0

精彩评论

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

关注公众号