0
我有一個奇怪的情況,在一個按鈕單擊事件我添加計時器到NSRunLoop應該在'x'分鐘後觸發。但是,如果iPad在'x'分鐘之前進入睡眠狀態,並且計時器值已達到其「x」值,並且之後再次打開我的應用程序,則不會顯示警報。當iPad處於睡眠模式時,用於顯示UIAlertView的NSRunLoop
因此,如果計時器時間到了,iPad處於睡眠模式,它應該會在我重新啓動應用程序後顯示警報。以下是我的代碼。
NSTimer *uiTimer = [NSTimer timerWithTimeInterval:[x intValue] * 60 target:self selector:@selector(fireTheMethod:) userInfo:nil repeats:NO];
[[NSRunLoop mainRunLoop] addTimer:uiTimer forMode:NSRunLoopCommonModes];
-(void) fireTheMethod
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Message" delegate:self cancelButtonTitle:nil otherButtonTitles:@"Ok", nil];
[alert show];
}
我認爲你應該去本地通知,而不是顯示警報。 – Pawan