ios 对话框 弹框,输入对话框 普通对话框

news/2024/7/20 23:10:56 标签: ios, 对话框, 弹框

1 普通对话框

  UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"a"                                                                    message:@"alert12222fdsfs"                                                       preferredStyle:UIAlertControllerStyleAlert];     
  UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
     handler:^(UIAlertAction * action) {
                
   }];
  UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault                                                        handler:^(UIAlertAction * action) {
                
            }];
    [alert addAction:defaultAction];
    [alert addAction:cancelAction];
   [self presentViewController:alert animated:YES completion:nil];

在这里插入图片描述

2 输入对话框

 //对话框添加文本输入框
                UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"标题"
                                                                               message:@"啊啊啊啊啊"
                                                                        preferredStyle:UIAlertControllerStyleAlert];
                
                UIAlertAction* okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
                                                                      handler:^(UIAlertAction * action) {
                                                                          //得到文本信息  进行后续处理
                                                                          for(UITextField *text in alert.textFields){
                                                                              NSLog(@"text = %@", text.text);
                                                                          }
                                                                      }];
                UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel
                                                                     handler:^(UIAlertAction * action) {
                                                                         //响应事件
                                                                         NSLog(@"action = %@", alert.textFields);
                                                                     }];
                [alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
                    textField.placeholder = @"用户名";
                }];
                [alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
                    textField.placeholder = @"密码";
                    textField.secureTextEntry = YES;
                }];
                
                [alert addAction:okAction];
                [alert addAction:cancelAction];
                [self presentViewController:alert animated:YES completion:nil];

在这里插入图片描述

3 密码输入对话框

 UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"支付" message:@"10.0" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
            alertView.alertViewStyle = UIAlertViewStyleSecureTextInput;
   [alertView show];

在这里插入图片描述

4 UIAlertController显示ActionSheet

    //弹出框列表选择
   UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"aa"
                                                                              message:@"Ta a a a "
                                                                       preferredStyle:UIAlertControllerStyleActionSheet];
               
    UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel
                                                                     handler:^(UIAlertAction * action) {
                                                                       
                                                                     }];
   UIAlertAction* deleteAction = [UIAlertAction actionWithTitle:@"删除" style:UIAlertActionStyleDestructive
                                                                    handler:^(UIAlertAction * action) {
                                                                      
                                                                    }];
   UIAlertAction* saveAction = [UIAlertAction actionWithTitle:@"保存" style:UIAlertActionStyleDefault
                                                                    handler:^(UIAlertAction * action) {
                                                                       
                            }];
      [alert addAction:saveAction];
    [alert addAction:cancelAction];
     [alert addAction:deleteAction];
      [self presentViewController:alert animated:YES completion:nil];

在这里插入图片描述


http://www.niftyadmin.cn/n/5171068.html

相关文章

20231111-读取当前文件夹中所有图片名称并写入TXT文本中

使用VBScript,存在问题(当图片名称中有中文时,保存的TXT文本为ANSI编码) Dim FileSystem, Folder, File, TextFile 创建文件系统对象 Set FileSystem CreateObject("Scripting.FileSystemObject") 获取当前目录路径 S…

asp.net core weapi 结合identity完成登录/注册/角色/权限分配

1.安装所需要的nuget包 <PackageReference Include"Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version"6.0.24" /><PackageReference Include"Microsoft.EntityFrameworkCore" Version"6.0.24" /><PackageR…

黑窗口连接远程服务

ssh root192.168.x.x 回车输入密码 查看docker docker ps 停止正在运行的服务 docker stop xxxxx 删除服务 docker rm xxxxx 查看镜像 docker images 删除镜像 docker rmi xxxxx 删除镜像 启动并运行整个服务 docker compose up -d jar包名称 idea 使用tcp方式连接docker 配置d…

电力计量溯源

一、引言 电力计量是电力系统中非常重要的环节&#xff0c;它涉及到电力交易的公正性和准确性。为了保证电力计量的准确性&#xff0c;我们需要对计量设备进行校准、量值传递与溯源、计量设备误差、计量标准建立、量值传递溯源图、计量标准考核、计量人员培训、计量设备维护、…

mysql.sock找不到怎么解决?

当我们连接mysql时找不到mysql.sock的时候会出现下列情况&#xff1a; cant connect to mysql server through socket /tmp/mysql.sock 解决方法&#xff1a; &#xff08;1&#xff09;找到mysql.sock 使用 find / -name mysql.sock 进行寻找。 如果找不到&#xff0c;那…

Ubuntu(WSL2) 安装最新版本的 GCC

要在 Ubuntu 上安装最新版本的 GCC&#xff0c;可以通过以下步骤进行操作&#xff1a; 1. 打开终端&#xff08;Terminal&#xff09; 2. 更新软件包列表&#xff0c;确保系统使用最新的软件包信息&#xff0c;运行以下命令&#xff1a; sudo apt update 3. 安装 GCC 软件包…

开源Gimp动态压感笔刷设置方法

一、问题描述 开源绘画工具的Gimp的笔刷压感在哪里控制和开启呢&#xff1f; 二、解决方法 1、Gimp有专用的笔刷集&#xff1a;如下图。开启需要在主窗口window下拉菜单开启&#xff0c;或在右侧面板里的左箭头按钮里打开。一般绘画够用了。比用自定义特殊笔刷。 2、如果要调…

【C++初阶】二、入门知识讲解(引用、内联函数、auto关键字、基于范围的for循环、指针空值nullptr)

相关代码gitee自取&#xff1a; C语言学习日记: 加油努力 (gitee.com) 接上期&#xff1a; 【C初阶】一、入门知识讲解 &#xff08;C关键字、命名空间、C输入&输出、缺省参数、函数重载&#xff09;-CSDN博客 六 . 引用 &#xff08;1&#xff09;. 引用的概念和特性…