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

1 普通对话框

objectivec 复制代码
  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 输入对话框

objectivec 复制代码
 //对话框添加文本输入框
                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 密码输入对话框

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

4 UIAlertController显示ActionSheet

objectivec 复制代码
    //弹出框列表选择
   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];
相关推荐
2501_916007472 小时前
iOS 压力测试的工程化体系,构建高强度、多维度、跨工具协同的真实负载测试流程
android·ios·小程序·uni-app·cocoa·压力测试·iphone
2501_916008894 小时前
API接口调试全攻略 Fiddler抓包工具、HTTPS配置与代理设置实战指南
前端·ios·小程序·https·fiddler·uni-app·webview
2501_915921435 小时前
iOS 开发者工具推荐,构建从调试到性能优化的多维度生产力工具链(2025 深度工程向)
android·ios·性能优化·小程序·uni-app·iphone·webview
00后程序员张7 小时前
全面解析网络抓包工具使用:Wireshark和TCPDUMP教程
网络·ios·小程序·uni-app·wireshark·iphone·tcpdump
游戏开发爱好者87 小时前
Mac 抓包软件怎么选?从 HTTPS 调试、TCP 数据流分析到多工具协同的完整抓包方案
tcp/ip·macos·ios·小程序·https·uni-app·iphone
马拉萨的春天9 小时前
iOS中广告SDK如何判断一个广告是否真实展示
macos·ios·cocoa
ajassi200010 小时前
开源 Objective-C IOS 应用开发(十九)视频的播放
ios·开源·objective-c
2501_9159184110 小时前
苹果上架 iOS 应用的工程实践,一次从零到上线的完整记录
android·ios·小程序·https·uni-app·iphone·webview
ajassi200011 小时前
开源 Objective-C IOS 应用开发(二十二)自定义控件--车速仪表盘
ios·开源·objective-c
從南走到北11 小时前
JAVA国际版同城跑腿源码快递代取帮买帮送同城服务源码支持Android+IOS+H5
android·java·ios·微信小程序