2011-09-30 78 views

回答

1

您可以使用定時器一段時間後,關閉警報,例如:

[[NSTimer scheduledTimerWithTimeInterval:2 
           target:self 
           selector:@selector(closeAlert:) 
           userInfo:nil 
           repeats:NO] retain]; 

欲瞭解更多信息,請看這裏:NSTimer Class Reference

0

可以顯示幾秒鐘後解除警報。 類似這樣的:(5秒後關閉)

UIAlertView *yourAlert = [[UIAlertView alloc]initWithTitle:@"title" message:@"message" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil]; 
     [yourAlert show]; 
     [self performSelector:@selector(dismiss:) yourAlert afterDelay:5.0]; 



-(void)dismiss:(UIAlertView*)alert 
{ 
    [alert dismissWithClickedButtonIndex:0 animated:YES]; 
} 
相關問題