//创建信息窗体 初始化
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"信息错误" message:@"用户名或密码不正确" preferredStyle:UIAlertControllerStyleAlert];
//创建执行操作 title 是显示的按键信息 style是按键类型 handler是按键要进行的操作
UIAlertAction *action = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
UIAlertAction *actionDefault = [UIAlertAction actionWithTitle:@"默认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//退出界面
[self dismissViewControllerAnimated:YES completion:nil];
}];
//添加操作
[alert addAction:action];
[alert addAction:actionDefault];
//显示弹框 UIAlertController 继承于UIViewController 所以用ViewController的弹出方法
[self presentViewController:alert animated:YES completion:nil];