标签:style blog color ar for sp div on log
UIAlertView的消失其实是触发了一个dismiss事件,注意removefromSubview是行不通的,我们可以通过代码摸你点击了某个按钮来让UIAlertView自动消失.
通过设置一个定时器,可以设置多少秒之后自动消失.
代码实现:
- (void)popAlertView { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"恭喜,注册成功" delegate:self cancelButtonTitle:nil otherButtonTitles:@"取消", nil]; self.alertView = alertView; //设置定时器,1.5秒后自动消失. [NSTimer scheduledTimerWithTimeInterval:1.5f target:self selector:@selector(performDismiss:) userInfo:nil repeats:NO]; [alertView show]; } -(void)performDismiss:(NSTimer *)timer { [self.alertView dismissWithClickedButtonIndex:0 animated:NO]; }
标签:style blog color ar for sp div on log
原文地址:http://www.cnblogs.com/shaohuaios/p/4045172.html