1.一般設(shè)置兩個選項
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:@"提示標(biāo)題" 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];