【代码笔记】iOS-UIAlertView3秒后消失

来源:互联网 发布:himall2.6官方版源码 编辑:程序博客网 时间:2024/05/17 13:41

一,效果图。

二,代码。

复制代码
- (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];    }}