在app制作過程中竹海,需要使用到提示框自動消失的功能误证,下面寫出一種我常使用的方法:
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"提示信息" preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:alert animated:YES completion:nil];
//控制提示框顯示的時間為2秒
[self performSelector:@selector(dismiss:) withObject:alert afterDelay:2.0];
實現(xiàn)dismiss:方法
- (void)dismiss:(UIAlertController *)alert{
[alert dismissViewControllerAnimated:YES completion:nil];
}