开发者

Application event when screen becomes active

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜