美文网首页iOS技术集iOS Developer
iOS 自动消失提示框的实现

iOS 自动消失提示框的实现

作者: Swift社区 | 来源:发表于2017-05-11 16:45 被阅读250次

在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];

实现dismiss:方法

- (void)dismiss:(UIAlertController *)alert{
    [alert dismissViewControllerAnimated:YES completion:nil];
}

希望可以帮助大家
如果哪里有什么不对或者不足的地方,还望读者多多提意见或建议
iOS技术交流群:668562416

相关文章

网友评论

    本文标题:iOS 自动消失提示框的实现

    本文链接:https://www.haomeiwen.com/subject/konotxtx.html