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

编程入门 行业动态 更新时间:2024-10-26 02:37:41

ios <a href=https://www.elefans.com/category/jswz/34/1761322.html style=对话框 弹框,输入对话框 普通对话框"/>

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

1 普通对话框

  UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"a"                                                                    message:@"alert12222fdsfs"                                                       preferredStyle:UIAlertControllerStyleAlert];     UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefaulthandler:^(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:UIAlertActionStyleDefaulthandler:^(UIAlertAction * action) {//得到文本信息  进行后续处理for(UITextField *text in alert.textFields){NSLog(@"text = %@", text.text);}}];UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancelhandler:^(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:UIAlertActionStyleCancelhandler:^(UIAlertAction * action) {}];UIAlertAction* deleteAction = [UIAlertAction actionWithTitle:@"删除" style:UIAlertActionStyleDestructivehandler:^(UIAlertAction * action) {}];UIAlertAction* saveAction = [UIAlertAction actionWithTitle:@"保存" style:UIAlertActionStyleDefaulthandler:^(UIAlertAction * action) {}];[alert addAction:saveAction];[alert addAction:cancelAction];[alert addAction:deleteAction];[self presentViewController:alert animated:YES completion:nil];

更多推荐

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

本文发布于:2023-11-15 11:15:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1598668.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对话框   ios   弹框

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!