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. "《算法导论》之‘字符串’":字符串匹配

    本文主要叙述用于字符串匹配的KMP算法. 阮一峰的博文“字符串匹配的KMP算法"将该算法讲述得非常形象,可参考之. 字符串‘部分匹配值’计算 KMP算法重要的一步在于部分匹配值的计算.模仿& ...

  2. ffdshow 源代码分析 4: 位图覆盖滤镜(滤镜部分Filter)

    ===================================================== ffdshow源代码分析系列文章列表: ffdshow 源代码分析 1: 整体结构 ffds ...

  3. android最火的开源项目

    原文地址:http://www.csdn.net/article/2013-05-21/2815370-Android-open-source-projects-finale 此前,CSDN移动频道推 ...

  4. butternife Zelezny自动注入插件

    插件地址:http://plugins.jetbrains.com/plugin/7369 Products: IntelliJ IDEA, RubyMine, WebStorm, PhpStorm, ...

  5. uc伯克利人工分割图像.seg文件解析

    之前看到  http://www.eecs.berkeley.edu/Research/Projects/CS/vision/grouping/segbench/ 提供的人工图像分割的.seg格式 ...

  6. Oracle 中Return 和exit的区别

    在Oracle存储过程中,使用Return 时,如果执行到Return语句,会跳出整个语句(如果是循环,会跳出整个循环),将不再执行,也就是结束了整个存储过程. 下面就用一个例子来说明一下 ,这个存储 ...

  7. 恶补web之六:javascript知识(1)

    javascript(下称js)是一种轻量级编程语言,它可以插入html页面然后由浏览器执行. document.write("<h1>...</h1>") ...

  8. IT咨询顾问:一次吐血的项目救火

    年后的一个合作公司上线了一个子业务系统,对接公司内部的单点系统.我收到该公司的技术咨询:项目启动后没有规律的突然无法登录了,重新启动后,登录一断时间后又无法重新登录,对方技术人员一头雾水不知道什么原因 ...

  9. python--Numpy and Pandas 基本语法

    numpy和pandas是python进行数据分析的非常简洁方便的工具,话不多说,下面先简单介绍一些关于他们入门的一些知识.下面我尽量通过一些简单的代码来解释一下他们该怎么使用.以下内容并不是系统的知 ...

  10. Django(一)入门基础——hello world

    环境配置 windows7 python3.6 Django 2.0 PyCharm 2018.1 专业版(PS:不建议社区版,因为被"阉割"了很多功能,比如cmd的Termina ...