iOS7和iOS8之后的弹窗的使用

在iOS7之前的弹窗都是使用的传统的UIAlertView,代码如下:

//创建弹框

  UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"输入的数字不合理" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil, nil];

//显示弹框
 [alertView  show];

在iOS8以来的弹框方式变为:

//                2.3.1创建一个弹框
        UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:@"提示" message:@"输入的数字不合理" preferredStyle:UIAlertControllerStyleAlert];
        //        2.3.2添加取消按钮
        [alertVc addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
        //        2.3.3.显示
        [self presentViewController:alertVc animated:NO completion:nil];

  

原文地址:https://www.cnblogs.com/gaizuojia/p/4631714.html