//初始化方法.继承与UIViewController
//设置设置Title、message 、preferredStyle
//preferredStyle只有两种:UIAlertControllerStyleAlert和UIAlertControllerStyleActionSheet,是分别代表要代替的UIAlertView和UIActionSheet
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"测试" message:@"我是UIAlertController" preferredStyle:UIAlertControllerStyleAlert];
//添加按钮到UIAlertController
//1、创建UIAlertAction作为UIAlertController的按钮项;
//2、初始化使用方法了:actionWithTitle: style: handler:;
//3、设置Title(按钮名)、 style(按钮样式了类型3种:cancel,default,destructive)、handler(处理程序,点击按钮执行方法);
//4、添加 UIAlertAction至UIAlertController。
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消cancel" style:UIAlertActionStyleCancel handler:nil];
UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"默认default" style:UIAlertActionStyleDefault handler:nil];
UIAlertAction *resetAction = [UIAlertAction actionWithTitle:@"destructive" style:UIAlertActionStyleDestructive handler:nil];
[alertController addAction:cancelAction];
[alertController addAction:defaultAction];
[alertController addAction:resetAction];
//显示需要使用UIViewController的方法:presentViewController弹出视图控制器
[self presentViewController:alertController animated:YES completion:nil];