1.一般设置两个选项
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"密码修改成功" preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[self.navigationController popViewControllerAnimated:YES];
}]];
[alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
取消按钮做什么,在这里写
}]];
[self presentViewController:alert animated:YES completion:nil];
2,第二种方法
UIAlertController *alert =[UIAlertController alertControllerWithTitle:@"提示标题" message:@"提示信息" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *alert1 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
取消的操作
}];
UIAlertAction *alert2 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
确定的操作
}];
[alert addAction:alert1];
[alert addAction:alert2];
[self presentViewController:alert animated:YES completion:nil];