开发者

How do we check if the iphone is on standby mode?

开发者 https://www.devze.com 2022-12-12 09:56 出处:网络
How can we check if the iphone has gone into a standby mode and returns from that mode programmaticlly? I am using this to force it not to sleep during the game:

How can we check if the iphone has gone into a standby mode and returns from that mode programmaticlly? I am using this to force it not to sleep during the game:

application.idleTimerDisabled = YES;

But if the user uses the sleep button it messes up开发者_JS百科 with my game state in my code. Any help would be appreciated, thanks in advance.


Your application will be told that the device is locking. In your applicationDelegate you can implement the

- (void)applicationWillResignActive:(UIApplication *)application

and

- (void)applicationDidBecomeActive:(UIApplication *)application

methods, to receive the notifications.

When your application transitions to inactive no events will be dispatched for it so you will be unable to do anything meaningful. Save your state as the device goes to sleep, and restore it on wake.


The app delegate will get a applicationWillResignActive: message before the device goes to sleep.

0

精彩评论

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