2011-09-30 61 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]; 
} 
相关问题