弹出框提示的使用 - 不是很完善
来源:互联网 发布:增值税发票数据分析 编辑:程序博客网 时间:2024/05/25 19:57
ios7/8中的使用
// 1.从底部弹出提示(UIActionSheet已经被ios9弃用)UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"恭喜通关" delegate:nil cancelButtonTitle:@"取消" destructiveButtonTitle:@"确定" otherButtonTitles:@"其他", nil];[sheet showInView:self.view];// 2.在屏幕中间弹出提示UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"恭喜" message:@"通关了!!!!" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"好的", nil];alert.tag = 10;[alert show];// 3.弹出带输入框的弹框UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"数据展示" message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];// 设置对话框的类型alert.alertViewStyle = UIAlertViewStylePlainTextInput;// 取得唯一的那个文本框,显示英雄的名称[alert textFieldAtIndex:0].text = hero.name;[alert show];alert.tag = indexPath.row;
注意事项:
1.UIAlertView的tag值大的提示框优先弹出;
2.otherButtonTitles 可以输入多个值,并且都是提示框中的按钮
ios9中的使用
在ios9中使用 UIActionSheet 和 UIAlertView 会弹出警告(不报错可以用但是有警告)
'UIAlertView' is deprecated: first deprecated in iOS 9.0 - UIAlertView is deprecated. Use UIAlertController with a
preferredStyle of UIAlertControllerStyleAlert instead
// 1.弹出普通提示框// 初始化提示框UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"恭喜" message:@"通关了!!!!" preferredStyle:UIAlertControllerStyleAlert];//增加一个‘确定’按钮[alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action){ //点击提示框按钮后响应的代码}]];// 弹出提示框[self presentViewController:alert animated:true completion:nil];// 2.弹出带文本框的提示框UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"数据展示" message:nil preferredStyle:UIAlertControllerStyleAlert];// 添加确定按钮[alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { // 1.获取文本框的名称 NSString *name = alert.textFields[0].text; // 2.更新模型数据 MJHero *hero = self.heros[indexPath.row]; hero.name = name; // 全部刷新 //[self.tableView reloadData]; // 3.局部刷新 NSIndexPath *path = [NSIndexPath indexPathForRow:indexPath.row inSection:0]; [self.tableView reloadRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationFade];}]];// 添加取消按钮[alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];// 添加文本框[alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) { textField.text = hero.name;}];// 在控制器中加载alert控件[self presentViewController:alert animated:true completion:nil];
UIAlertController 的 preferredStyle 参数说明:
UIAlertControllerStyleActionSheet 为底部弹出提示;
UIAlertControllerStyleAlert为屏幕中间弹出提示;UIAlertAction 的 style 参数说明:
UIAlertActionStyleDefault 为普通按钮
UIAlertActionStyleCancel 为取消按钮
UIAlertActionStyleDestructive 为危险操作按钮
0 0
- 弹出框提示的使用 - 不是很完善
- iphone 提示(弹出)框的使用
- 用c语言写的kmeans算法,不是很完善
- android系统中常用的弹出提示框使用代码
- response跳转页面前弹出alert提示框分析及常见的弹出框使用
- 整理:手机端弹出提示框,使用的bootstrap中的模态框(modal,弹出层),比kendo弹出效果好
- 使用UIPickerView实现弹出提示框
- 系统提示弹出“XXX.EXE不是有效Win32应用程序”的错误情况如何解决
- ios系统提示音的使用(不是铃声)
- 关于用户打分的,不是直接弹出框的那种
- 两种弹出提示框的方式
- c#弹出提示框的一种方法
- android中常用的弹出提示框
- 右下角弹出一个小的提示框
- android中常用的弹出提示框
- android中常用的弹出提示框
- android中常用的弹出提示框
- android中常用的弹出提示框
- MyEclipse使用总结——MyEclipse10安装SVN插件
- maven方式的下载jar maven的id查询
- 集合初探(七)
- Shell Script 基础
- RDD创建彻底解密
- 弹出框提示的使用 - 不是很完善
- chrdevs数组
- Unable to add window -- token android.os.BinderProxy@164db98f is not valid解决办法f
- Android 自定义控件:入门篇之自定义验证码
- office2007每次打开都要配置文件,怎么取消配置
- 2015 年 Ruby 大盘点
- swift数组与字典
- Linux 双物理网卡绑定成一个虚拟网卡
- 网络加密解密原理(三) RSA加密解密及数字签名Java实现