2012年9月10日 星期一

iOS 中如何禁止進入螢幕保護狀態

在 iOS 程式中,如果希望我們的程式不要進入螢幕保護狀態,例如導航軟體一樣,作法其實很簡單,只要使用
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];

這樣程式就不會進入螢幕保護狀態了。但是如果使用者手動的方式進入 Lock Mode ,而重新解鎖之後你會發現,原本在執行的 Server 都被關閉了,這個時候你可以在下列函數中重新啟動


- (void)applicationWillEnterForeground:(UIApplication *)application

{

// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.

/* Start Server */

}

沒有留言:

張貼留言