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];
相关推荐
陈皮话梅糖@3 小时前
iOS 集成ffmpeg
ios·ffmpeg
幽夜落雨3 小时前
ios老版本应用安装方法
ios
胖虎111 小时前
实现 iOS 自定义高斯模糊文字效果的 UILabel(文末有Demo)
ios·高斯模糊文字·模糊文字
_可乐无糖2 天前
Appium 检查安装的驱动
android·ui·ios·appium·自动化
胖虎12 天前
iOS 网络请求: Alamofire 结合 ObjectMapper 实现自动解析
ios·alamofire·objectmapper·网络请求自动解析·数据自动解析模型
开发者如是说3 天前
破茧英语路:我的经验与自研软件
ios·创业·推广
假装自己很用心3 天前
iOS 内购接入StoreKit2 及低与iOS 15 版本StoreKit 1 兼容方案实现
ios·swift·storekit·storekit2
iOS阿玮3 天前
“小红书”海外版正式更名“ rednote”,突然爆红的背后带给开发者哪些思考?
ios·app·apple
刘小哈哈哈3 天前
iOS UIScrollView的一个特性
macos·ios·cocoa
忆江南的博客4 天前
iOS 性能优化:实战案例分享
ios