UIAlertView 和 UIAlertController

来源:互联网 发布:罗格朗开关质量 知乎 编辑:程序博客网 时间:2024/06/10 20:02

二者都可实现弹窗功能:
UIAlertView:

//用button触发- (void)button{    UIAlertView *alterView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"网络不给力...." delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"继续",@"再试一次", nil];    [alterView show];}

效果图

UIAlertController

- (void)button{    UIAlertController *controller = [UIAlertController alertControllerWithTitle:@"提示" message:@"网速不给力..." preferredStyle:(UIAlertControllerStyleAlert)];    [self presentViewController:controller animated:YES completion:nil];    UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleCancel) handler:nil];    UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"继续" style:(UIAlertActionStyleDefault) handler:nil];    UIAlertAction *action3 = [UIAlertAction actionWithTitle:@"再试一次" style:(UIAlertActionStyleDestructive) handler:nil];    [controller addAction:action1];    [controller addAction:action2];    [controller addAction:action3];}

效果图

二者区别和联系
这里写图片描述

0 0
原创粉丝点击