iOS:UIAlertView3秒后消失,iosuialertview3
投稿于 被查看 18542 次 评论:275
iOS:UIAlertView3秒后消失,iosuialertview3
一,效果图。二,代码。
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIAlertView* alert = [[UIAlertView alloc]initWithTitle:nil message:@"此信息3秒后消失" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil, nil];
[alert show];
[self performSelector:@selector(dismissAlert:) withObject:alert afterDelay:3.0];
}
- (void)dismissAlert:(UIAlertView*)alert {
if ( alert.visible ) {
[alert dismissWithClickedButtonIndex:alert.cancelButtonIndex animated:YES];
}
}
用户评论