弹出提醒对话框

来源:互联网 发布:卢洁云淘宝店衣服好吗 编辑:程序博客网 时间:2024/04/29 18:14

以下为弹出对话框的代码

  //1 创建提醒控制器 UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"消息" message:@"消息详情" preferredStyle:UIAlertControllerStyleAlert];//preferredStyle 对话框模式 可选择中部或底部弹出    2 // 给提醒控制器添加一个文本输入框 [alertC addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {        textField.text = @"文本框显示内容" ;    }];     3 // 创建取消按钮     //style 可选择按钮的样式     UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {        //此处添加点击"取消"按钮后的操作    }];    // 创建确定按钮    UIAlertAction *ok = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {        //此处添加点击"确定"按钮后的操作    }];   4  // 给提醒框添一个取消按钮    [alertC addAction:cancel];      // 给提醒控制器添加确定按钮    [alertC addAction:ok];   5 // 让提醒控制器显示出来   //此方法为控制器方法 self是控制器     [self presentViewController:alertC animated:YES completion:nil];
0 0
原创粉丝点击