iOS——AlertView利用定时器自动消失

UIAlertView *alert;
- (IBAction)Open:(id)sender {
alert = [[UIAlertView alloc]
initWithTitle:@”msg” message:@”sss” delegate:self cancelButtonTitle:@”取消” otherButtonTitles:@”确定”, nil];
[NSTimer scheduledTimerWithTimeInterval:5.0f target:self selector:@selector(performDismiss:) userInfo:nil repeats:NO];
[alert show];

}

-(void)performDismiss:(NSTimer*)timer
{
[alert dismissWithClickedButtonIndex:0 animated:NO];

}

你可能感兴趣的:(iOS——AlertView利用定时器自动消失)