IOS初级:UIAlertController


- (IBAction)signOutAction:(id)sender {
    //初始化,StyleActionSheet是对话框的样式
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"是否注销?" message:@"真的要注销吗" preferredStyle:UIAlertControllerStyleActionSheet];
    //添加按钮
    [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];//nil表示不需要任何操作
    [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
        //点击确定时要实现的逻辑,这里是返回上级控制器
        [self.navigationController popViewControllerAnimated:YES];
    }]];
    //弹出UIAlertController
    [self presentViewController:alert animated:YES completion:NULL];
}


posted on 2015-06-16 16:59  阮減显  阅读(91)  评论(0编辑  收藏  举报

导航