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的更多相关文章

  1. UIAlertView、 UIActionSheet

    一.UIAlertView. UIActionSheet都是ios系统自带的弹出式对话框,当UIAlertView或UIActionSheet弹出来时用户无法与应用界面中的其它控件交互,UIAlert ...

  2. iOS开发——UI篇Swift篇&UIAlertView/UIActionSheet

    UIAlertView/UIActionSheet UIAlertView //一个按钮的提醒 @IBAction func oneButtonAler() { //创建单一按钮提醒视图 let on ...

  3. UIAlertView、UIActionSheet兼容iOS8

    链接地址:http://blog.csdn.net/nextstudio/article/details/39959895?utm_source=tuicool 1.前言 iOS8新增了UIAlert ...

  4. 用block将UIAlertView与UIActionSheet统一起来

    用block将UIAlertView与UIActionSheet统一起来 效果 1. 将代理方法的实例对象方法转换成了类方法使用 2. 要注意单例block不要长期持有,用完就释放掉 源码 https ...

  5. iOS8以后UIAlertView和UIActionSheet两种alert页面都将通过UIAlertController来创建

    1. Important: UIAlertView is deprecated in iOS 8. (Note that UIAlertViewDelegate is also deprecated. ...

  6. UIAlertView及UIActionSheet 在ios8极其以下版本的兼容问题解决方案

    本文转载至 http://www.aichengxu.com/view/35326 UIAlertView及UIActionSheet在ios8中被放弃,其功能将完全由UIAlertControlle ...

  7. iOS 8 中 UIAlertView 和 UIActionSheet 河里去了?

    iOS 8 中 UIAlertView 和 UIActionSheet 河里去了? 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商 ...

  8. iOS:简单使用UIAlertVIew和UIActionSheet

    做iOS开发的同学想必都用过UIAlertVIew或者UIActionSheet.UIAlertVIew 可以弹出一个出现在屏幕中间的提示视图,给用户展示信息,并让用户自己选择操作,UIActionS ...

  9. UIAlertView 与 UIActionSheet (提示用户)的使用方法

    UIAlertView 提示用户  帮助用户选择框 //    UIAlertView *alterView = [[UIAlertView alloc] initWithTitle:@"警 ...

随机推荐

  1. The ENU localization is not supported by this SQL Server media

    今儿在给服务器装sqlserver2008R2时遇到一个问题"The ENU localization is not supported by this SQL Server media&q ...

  2. linux grep 和 sed使用

    http://www.cnblogs.com/zhuyp1015/archive/2012/07/01/2572289.html 听说过sed 和 awk 比较强大,专门学习了一下. 使用这些shel ...

  3. 一键安装Android开发环境

    一键安装Android开发环境 1 下载tadp-3.0r4-linux-x64.run 进入下面的地址下载: https://developer.nvidia.com/gameworksdownlo ...

  4. MTK如何烧录IMEI码(俗称串号)

    先介绍一下使用环境 主控:MT6582VX android版本:4.4.2 操作系统:windows XP SN烧录工具:SN_Write_tool_exe_v2.1420.00 首先介绍一下IMEI ...

  5. how tomcat works 总结

    希望各位网友在看完<<how tomcat works>>一书或者鄙人的tomcat专栏文章后再看这篇博客 这里主要是梳理各个章节的核心概念 第一章 一个简单的Web服务器 第 ...

  6. 面试之路(27)-链表中倒数第K个结点

    代码的鲁棒性: 所谓的鲁棒性是指能够判断输入是否合乎规范,能对不和规范的程序进行处理. 容错性是鲁棒性的一个重要体现. 防御性编程有助于提高鲁棒性. 切入正题,我可不是标题党: 链表倒数第k个节点 列 ...

  7. HBase 协处理器实现二级索引

    HBase在0.92之后引入了coprocessors,提供了一系列的钩子,让我们能够轻易实现访问控制和二级索引的特性.下面简单介绍下两种coprocessors,第一种是Observers,它实际类 ...

  8. C#在PDF中如何以不同颜色高亮文本

    高亮的文本有助于阅读者快速有效地获取文章关键信息.在PDF文件中,对文章的不同文本,关键词.句等进行不同颜色的文本高亮操作,可以使阅读者在阅读过程中有效地区分不同高亮颜色文本的意义.在下面的示例中,我 ...

  9. [Other]在 Docker 当中搭建 Docfx 站点

    一.简介 Docfx 是微软开发的一款开源的文档生成工具,其默认支持 C# 与 VB.Net 这两种项目的文档生成,支持 DotNetCore 项目,并且还可以打包成一个静态的 Web 站点,而且还支 ...

  10. 新装的主机没有ifconfig,route等命令,怎么查找对应的安装包

    公司最近有台新装的主机,主机上一些常用的命令都没有,比如说ifconfig,route等命令. 没有这些命令主机很难工作,所以我们就需要把他安装上 第一种方法:是你需要知道对应的是那个包 比如说ifc ...