2014-10-05 80 views

回答

0

可以使用的NSTimer

實現這個功能
[NSTimer scheduledTimerWithTimeInterval:@"time" target:self selector:@selector(targetMethod:) userInfo:nil repeats:NO]; 

-(void)targetMethod 
{ 
     //enter code here` 
} 
0

請查看此問題的接受答案。它應該回答你的問題。

iPhone: Detecting user inactivity/idle time since last screen touch

編輯:

可以使用NSTimer class

This question will help you with NSTimer。好像你正在尋找一個非常基本的實現它,你通常會使用

NSTimer scheduledTimerWithTimeInterval... 

方法

+0

感謝您的回覆,但這將註銷,如果你保持不活動的一段時間,但我也想註銷用戶,如果他使用的應用程序即登出後2小時登錄時間 – rocky171 2014-10-05 02:01:35

+0

感謝NewEngland它的工作,但我有1個問題,我可以做同樣的事情與uilocalnotificati上? – rocky171 2014-10-05 02:15:15

+0

UILocalNotification更適合您的應用程序在後臺運行(或屏幕關閉時)。但是當你的應用處於前臺時,你仍然應該使用NSTimer – MendyK 2014-10-05 03:00:20

相關問題