UIAlertControl的使用对比与UIAlertView和UIActionSheet
1.UIAlertVIew以-(void)show的方法显示:
- (void)viewDidLoad {
[super viewDidLoad];
//UIAlertView的使用
[self showAlert];
//UIAcyionSheet使用
// [self showAction];
#pragma mark [self showAlertController];方法不可以放在此处因为UIAlertControl继承与UIViewController
//UIAlertControl的使用
// [self showAlertController];
}
UIAlertView 的实现:
-(void)showAlert{
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"紧急通知" message:@"由于幸福指数哦不断下降,经调查和假期成线性关系,特批以后工作一天休息一天" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
alertView.alertViewStyle = UIAlertViewStyleDefault;
/*
UIAlertViewStyleDefault ,默认
UIAlertViewStyleSecureTextInput, 密码输入框
UIAlertViewStylePlainTextInput, 文本输入框
UIAlertViewStyleLoginAndPasswordInput 用户及密码
*/
[alertView show];
}
#pragma mark - UIALertDelegate
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
switch (buttonIndex) {
case 0:
NSLog(@"点击%ld",buttonIndex);
break;
case 1:
NSLog(@"点击%ld",buttonIndex);
break;
default:
break;
}
}

2.UIActionSheet的使用
-(void)showAction{
UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:@"请假\n选择请假类型" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"事假" otherButtonTitles:@"病假",@"产假", nil];
[actionSheet showInView:self.view];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark UIActionSheetDelegate
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
switch (buttonIndex) {
case 0:
NSLog(@"点击%ld",buttonIndex);
break;
case 1:
NSLog(@"点击%ld",buttonIndex);
break;
case 2:
NSLog(@"点击%ld",buttonIndex);
break;
default:
break;
}
}

3.UIAlertControl的简单使用
-(void)showAlertController{
//UIAlertControllerStyle两种类型UIAlertControllerStyleAlert类似UIAlertView
//UIAlertControllerStyleActionSheet类似UIActionSheet
UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"you and me" message:@"together forever" preferredStyle:UIAlertControllerStyleAlert];
//block代码块取代了delegate
UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"No matter of life and death" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
NSLog(@"生死相依");
}];
UIAlertAction *alertTwo = [UIAlertAction actionWithTitle:@"Share weal and woe" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
NSLog(@"同甘共苦");
}];
UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Sure" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
NSLog(@"确定");
}];
[alertControl addAction:actionOne];
[alertControl addAction:alertTwo];
[alertControl addAction:alertthree];
//UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
[alertControl addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.text = @"for love ";
}];
[self presentViewController:alertControl animated:YES completion:nil];
}

UIAlertControl的使用对比与UIAlertView和UIActionSheet的更多相关文章
- UIAlertView、 UIActionSheet
一.UIAlertView. UIActionSheet都是ios系统自带的弹出式对话框,当UIAlertView或UIActionSheet弹出来时用户无法与应用界面中的其它控件交互,UIAlert ...
- iOS开发——UI篇Swift篇&UIAlertView/UIActionSheet
UIAlertView/UIActionSheet UIAlertView //一个按钮的提醒 @IBAction func oneButtonAler() { //创建单一按钮提醒视图 let on ...
- UIAlertView、UIActionSheet兼容iOS8
链接地址:http://blog.csdn.net/nextstudio/article/details/39959895?utm_source=tuicool 1.前言 iOS8新增了UIAlert ...
- 用block将UIAlertView与UIActionSheet统一起来
用block将UIAlertView与UIActionSheet统一起来 效果 1. 将代理方法的实例对象方法转换成了类方法使用 2. 要注意单例block不要长期持有,用完就释放掉 源码 https ...
- iOS8以后UIAlertView和UIActionSheet两种alert页面都将通过UIAlertController来创建
1. Important: UIAlertView is deprecated in iOS 8. (Note that UIAlertViewDelegate is also deprecated. ...
- UIAlertView及UIActionSheet 在ios8极其以下版本的兼容问题解决方案
本文转载至 http://www.aichengxu.com/view/35326 UIAlertView及UIActionSheet在ios8中被放弃,其功能将完全由UIAlertControlle ...
- iOS 8 中 UIAlertView 和 UIActionSheet 河里去了?
iOS 8 中 UIAlertView 和 UIActionSheet 河里去了? 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商 ...
- iOS:简单使用UIAlertVIew和UIActionSheet
做iOS开发的同学想必都用过UIAlertVIew或者UIActionSheet.UIAlertVIew 可以弹出一个出现在屏幕中间的提示视图,给用户展示信息,并让用户自己选择操作,UIActionS ...
- UIAlertView 与 UIActionSheet (提示用户)的使用方法
UIAlertView 提示用户 帮助用户选择框 // UIAlertView *alterView = [[UIAlertView alloc] initWithTitle:@"警 ...
随机推荐
- 使用Ext JS,不要使用页面做组件重用,尽量不要做页面跳转
今天,有人请教我处理办法,问题是: 一个Grid,选择某条记录后,单击编辑后,弹出编辑窗口(带编辑表单),编辑完成后单击保存按钮保存表单,并关闭窗口,刷新Grid. 这,本来是很简单的,但囿于开发人员 ...
- nodejs书籍
http://product.dangdang.com/23371791.html#catalog https://www.byvoid.com/project/node http://www.ama ...
- FFMPEG结构体分析:AVIOContext
注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrame FFMPEG结构体分析:AVFormatContext FFMPEG结构体分析:AVCodecConte ...
- 中国象棋游戏Chess(3) - 实现走棋规则
棋盘的绘制和走棋参看博文:中国象棋游戏Chess(1) - 棋盘绘制以及棋子的绘制,中国象棋游戏Chess(2) - 走棋 现在重新整理之前写的代码,并且对于每个棋子的走棋规则都进行了限制,不像之前那 ...
- 快速熟悉Oracle索引
一.索引 1.1 什么是索引? 一种用于提升查询效率的数据库对象: 通过快速定位数据的方法,减少磁盘的输入输出操作: 索引信息与表独立存放: Oracle数据库自动使用和维护索引. 1.2 索引分类 ...
- CSS3概述
首先我们了解下什么是css3,css3是css技术的一个升级.css3中并没有采用总体结构,而是采用分工协作的模块化结构. css3中的模块 模块名称 功能描述 basic box model 定义各 ...
- html5中新增的属性和删除的属性
一.表单新增的属性 1.对input(type="text").select.textarea与button元素指定autofocus属性,它以指定属性的方式让元素在画面打开时自动 ...
- SDWebImage底层实现原理
SDWebImage底层实现有沙盒缓存机制,主要由三块组成 1.内存图片缓存2.内存操作缓存3.磁盘沙盒缓存内部实现过程:第一步,下载SDWebImage,导入工程. 第二步,在需要的地方导入头文件 ...
- angularjs指令中的compile与link函数详解
这篇文章主要介绍了angularjs指令中的compile与link函数详解,本文同时诉大家complie,pre-link,post-link的用法与区别等内容,需要的朋友可以参考下 通常大家在 ...
- miniUI input设置默认值,js获取年月注意事项,数据库nvl函数使用
2017-6-5周一,今天碰到的一个需求是:两税附征模块进入页面筛选时间默认值为当前月的上一个月,并根据筛选结果显示数据,我们用的框架为miniUI. 坑1: 默认值设置,刚刚接触miniUI,对里面 ...