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];
相关推荐
2401_8658548810 小时前
iOS应用想要下载到手机上只能苹果签名吗?
后端·ios·iphone
HackerTom1 天前
iOS用rime且导入自制输入方案
ios·iphone·rime
良技漫谈1 天前
Rust移动开发:Rust在iOS端集成使用介绍
后端·程序人生·ios·rust·objective-c·swift
2401_852403551 天前
高效管理iPhone存储:苹果手机怎么删除相似照片
ios·智能手机·iphone
星际码仔1 天前
【动画图解】是怎样的方法,能被称作是 Flutter Widget 系统的核心?
android·flutter·ios
emperinter1 天前
WordCloudStudio:AI生成模版为您的文字云创意赋能 !
图像处理·人工智能·macos·ios·信息可视化·iphone
关键帧Keyframe2 天前
音视频面试题集锦第 8 期
ios·音视频开发·客户端
pb82 天前
引入最新fluwx2.5.4的时候报错
flutter·ios
袁代码2 天前
Swift 开发教程系列 - 第4章:函数与闭包
ios·swift·ios开发
#摩斯先生3 天前
IOS 防截屏实现
ios·xcode