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. 算法精解:最小二乘法C实现

    计量经济学研究的直接目的是确定总体回归函数Yi=B1+B2Xi+ui,然而能够得到的只是来自总体的若干样本的观测值,要用样本信息建立的样本回归函数尽可能"接近"地去估计总体回归函数 ...

  2. 【Java编程】Java基本数据类型

    在较前面的一篇博文<C/C++基本数据类型>中,我主要介绍了c/c++的基本数据类型.我们知道C语言没有具体规定各类数据类型所占内存的字节数,只要求long型数据长度不小于int型,sho ...

  3. C语言之选择排序

    选择法排序是相对好理解的排序算法.假设要对含有n个数的序列进行升序排列,算法步骤是: 1.从数组存放的n个数中找出最小数的下标(算法见下面的"求最值"),然后将最小数与第1个数交换 ...

  4. 【55】java异常机制剖析

    一.为什么要使用异常 首先我们可以明确一点就是异常的处理机制可以确保我们程序的健壮性,提高系统可用率.虽然我们不是特别喜欢看到它,但是我们不能不承认它的地位,作用.有异常就说明程序存在问题,有助于我们 ...

  5. 部署与管理ZooKeepe

    1.部署 本章节主要讲述如何部署ZooKeeper,包括以下三部分的内容: 1. 系统环境 2. 集群模式的配置 3. 单机模式的配置 系统环境和集群模式配置这两节内容大体讲述了如何部署一个能够用于生 ...

  6. LeetCode(53)-Binary Tree Paths

    题目: Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree ...

  7. javascript中正则表达式和ruby中的一点差异

    看到一个例子,不过这个例子中正则表达式的格式貌似是错的: Function.prototype.get_name = function(){ return this.name || this.toSt ...

  8. 关于jasperreport对应java打印机的解决方案

    对于jasperreport打印这个功能,遇到了一大堆问题,也只能一点一点解决我: 1.现在我用的是jasperreport.jar是4.6版本. (1).因为网上查到:6.0以上版本已经不再支持ja ...

  9. 解决ecshop3.6 H5版本公告页面为空的修改办法

    ecshop3.6公告页面打开如下,页面完全无效果,如下图. 经过简单美化后,有返回按钮,页面加以美化.如下图. 是不是要好看多了.简单修改几步即可. 修改文件 \appserver\resource ...

  10. div学习之div中dl-dt-dd的详解

    dl dt dd认识及dl dt dd使用方法 <dl> 标签用于定义列表类型标签. dl dt dd目录 dl dt dd介绍 结构语法 dl dt dd案例 dl dt dd总结 一. ...