iOS8新API UIAlertController

  近日在写一个提示框的时候,发现苹果把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可以接受用户的点击然后设置需要的下一步处理

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容