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];
相关推荐
dr李四维23 分钟前
iOS构建版本以及Hbuilder打iOS的ipa包全流程
前端·笔记·ios·产品运营·产品经理·xcode
️ 邪神30 分钟前
【Android、IOS、Flutter、鸿蒙、ReactNative 】自定义View
flutter·ios·鸿蒙·reactnative·anroid
比格丽巴格丽抱12 小时前
flutter项目苹果编译运行打包上线
flutter·ios
网络安全-老纪13 小时前
iOS应用网络安全之HTTPS
web安全·ios·https
1024小神16 小时前
tauri2.0版本开发苹果ios和安卓android应用,环境搭建和最后编译为apk
android·ios·tauri
lzhdim17 小时前
iPhone 17 Air看点汇总:薄至6mm 刷新苹果轻薄纪录
ios·iphone
安和昂17 小时前
【iOS】知乎日报第四周总结
ios
麦田里的守望者江20 小时前
KMP 中的 expect 和 actual 声明
android·ios·kotlin
_黎明21 小时前
【Swift】字符串和字符
开发语言·ios·swift
ZVAyIVqt0UFji1 天前
iOS屏幕共享技术实践
macos·ios·objective-c·cocoa