美文网首页
iOS8新API UIAlertController

iOS8新API UIAlertController

作者: saintPN | 来源:发表于2016-03-15 13:48 被阅读0次

  近日在写一个提示框的时候,发现苹果把uialertview禁止了,同时提供了一个新的api UIAlertController,使用起来也挺简单:

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"输入记录表名称" message:nil preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {}];

UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];

[alertController addAction:cancelAction];

[alertController addAction:okAction];

[self presentViewController:alertController animated:YES completion:nil];

  第一个方法是配置提示框的标题和显示信息,以及style,可以选择sheet或者alert;第二、三个方法是设置一个按钮,用户点击了之后alert就会消失,还有一个handler可以接受用户的点击然后设置需要的下一步处理

相关文章

网友评论

      本文标题: iOS8新API UIAlertController

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