//注销按钮时候的操作
- (IBAction)logOutButClick:(UIBarButtonItem *)sender {
//创建UIalercontroller对象
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"提示确定注销吗?" message:@"取消" preferredStyle:UIAlertControllerStyleActionSheet];
/** UIAlertActionStyleDefault = 0, 默认
UIAlertActionStyleCancel, 取消
UIAlertActionStyleDestructive 销毁
*/
// 创建确实按钮
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
//回到上个控制器
[self.navigationController popViewControllerAnimated:YES];
}];
// 创建取消按钮
UIAlertAction *cancle = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
//把这两个按钮添加到提示框中
[alertVC addAction:ok];
[alertVC addAction:cancle];
//弹出提示框
[self presentViewController:alertVC animated:YES completion:nil];
}
网友评论