ios中提示框的使用
来源:互联网 发布:辐射4男主角捏脸数据 编辑:程序博客网 时间:2024/06/16 00:16
旧版提示框
UIAlertView *alt=[[UIAlertView alloc]initWithTitle:@"友情提示" message:@"是否是成年人" delegate:self cancelButtonTitle:@"不满足" otherButtonTitles:@"满足", nil]; alt.delegate=self; [alt show];
UIAlertView获取按钮的点击事件需要使用代理的方式,代理类为:UIAlertViewDelegate。然后实现其方法,即可获取按钮的点击事件。
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ NSLog(@"%ld",buttonIndex);}
底部提示框
UIActionSheet *sheet=[[UIActionSheet alloc] initWithTitle:@"请选择城市" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"北京" otherButtonTitles:@"上海", nil]; [sheet showInView:self.view];
与上述提示框类似,代理为:UIActionSheetDelegate,点击的代理方法如下:
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{}
新版提示框
UIAlertController *controller=[UIAlertController alertControllerWithTitle:@"友情提示" message:@"是否购买" preferredStyle:UIAlertControllerStyleAlert];UIAlertAction *act1=[UIAlertAction actionWithTitle:@"买" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { }];UIAlertAction *act2=[UIAlertAction actionWithTitle:@"不买" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { }]; [controller addAction:act1]; [controller addAction:act2]; [self presentViewController:controller animated:YES completion:^{ }];
此提示框需要使用控件触发弹出。
新版ActionSheet
UIAlertController *controller=[UIAlertController alertControllerWithTitle:@"选择" message:@"请选择" preferredStyle:UIAlertControllerStyleActionSheet]; UIAlertAction *act1=[UIAlertAction actionWithTitle:@"买" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { }]; UIAlertAction *act2=[UIAlertAction actionWithTitle:@"不买" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { }]; [controller addAction:act1]; [controller addAction:act2]; [self presentViewController:controller animated:YES completion:^{ }];
取消提示框
[self dismissViewControllerAnimated:YES completion:^{ }];
阅读全文
0 0
- ios中提示框的使用
- ios中Alert提示框的简单使用
- iOS -iOS9中提示框(UIAlertController)的常见使用
- IOS开发之 ---- iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一)
- IOS开发之 ---- iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一)
- IOS开发之 ---- iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一)
- iOS中消息框提示的出现与自动消失
- iOS中自动消失提示框的实现
- 关于iOS中类似于Android的Toast短暂提示框
- iOS中自动消失提示框的实现
- iOS 使用MBProgressHUD 完成提示框的编写
- iOS入门编程1--iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一)
- ios开发 系统提示音的使用
- phonegap - 解决ios中使用定位的页面会跳出一个用户确认提示的问题
- IOS中使用本地通知为你的APP添加提示用户功能
- iOS中使用本地通知为你的APP添加提示用户功能
- iOS中实现提示框效果
- Android开发中提示框Toast、AlertDialog的使用!
- Python学习12_基本图形的绘制
- js参数值访问
- Python标准库之functools,itertools,operator
- python.snippet
- 字符串字符数组的赋值
- ios中提示框的使用
- 【数据处理】R语言--data.table介绍以及例子
- 选择排序
- PostgreSQL 10 流式物理、逻辑主从 最佳实践
- GC的算法和种类
- 负载均衡的几种算法Java实现代码
- JDBC 关闭顺序问题
- 我所理解的设计模式(C++实现)——命令模式(Command Pattern)
- 【如何快速的开发一个完整的iOS直播app】(原理篇)