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类似UIActionSheetUIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"you  and  me" message:@"together forever" preferredStyle:UIAlertControllerStyleAlert];//block代码块取代了delegateUIAlertAction *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];}

  

转载于:https://www.cnblogs.com/li--nan/p/4455702.html

UIAlertControl的使用对比与UIAlertView和UIActionSheet相关推荐

  1. iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一)

    本文转载至 http://blog.csdn.net/liuwuguigui/article/details/39494597 IOS8UIAlertViewUIActionSheet iOS8推出了 ...

  2. UIAlertController (UIActionSheet, UIAlertView is deprecated in iOS 8.)

    iOS 8 后 UIAlertView 和  UIActionSheet 都被合并到了 UIAlertController里面. 文档原文: Important: UIAlertView is dep ...

  3. UIAlertView UIActionSheet随笔笔记

    系统UIAlertView在很多地方有使用到,其创建的初始化的方法为: - (id)initWithTitle:(NSString *)title message:(NSString *)messag ...

  4. UIKit 框架之UIActionSheet

    UIAlertView和UIActionSheet相似,区别很小, 很容易理解. // // ViewController.m // UIActionSheet // // Created by Ci ...

  5. UIAlertView, UIAlertViewController

    iOS 8的新特性之一就是让接口更有适应性.更灵活,因此许多视图控制器的实现方式发生了巨大的变化.全新的UIPresentationController 在实现视图控制器间的过渡动画效果和自适应设备尺 ...

  6. (iOS-框架封装)iOS设计模式——MVC模式

    MVC模式是iOS编程中提到的最多次的设计模式,也是使用最频繁的设计模式之一.网络上有很多的MVC模式的分析文章,但都是从原理上来解释,很少能找到配套的案例来说明到底在实际的项目中要如何的使用这种模式 ...

  7. UIAlertAction添加输入框

    *  UIAlertController & UIAlertAction *  1. 在iOS8中,我们失去了两个非常简单的控件,那就是UIAlertView.UIActionSheet,取而 ...

  8. iOS开发第三方大全

    UI 下拉刷新 EGOTableViewPullRefresh- 最早的下拉刷新控件. SVPullToRefresh- 下拉刷新控件. MJRefresh- 仅需一行代码就可以为UITableVie ...

  9. iOS 常用第三方库及插件

    //菜单切换 https://github.com/pujiaxin33/JXCategoryView //各种导航栏样式 https://github.com/rickytan/RTRootNavi ...

最新文章

  1. 公司各个阶段 CTO 需要做什么?(下篇)
  2. 【Angular】服务(Service)
  3. .NetCore HttpClient发送请求的时候为什么自动带上了一个RequestId头部?
  4. Spring Boot YAML配置
  5. java学习(50):子类继承会优先调用父类的构造器
  6. 【腾讯优测干货分享】从压测工具谈并发、压力、吞吐量
  7. linux 查看登入记录_无时无刻,用 SimplyBook.me 管理者 App 查看客户预约排程!
  8. Function与Object
  9. 自动驾驶专题研究报告:自动驾驶产业链全梳理
  10. JavaScript 详说事件流(冒泡、捕获、传播、委托)
  11. 初级篇第三期:初识UI
  12. sdk manager的列表怎么消失了_腾讯安全SDK的Dll Dump研究
  13. Rust: mod文件、main文件调用
  14. 网际风全推数据接口_网际风千钧版 飞狐配套全推接口最新版(2013年5月10更新)...
  15. PS CC2019新手必学基础(首选项)设置
  16. python柱状图颜色_Python 绘制 柱状图
  17. 【若依vue框架学习】4.获取登录用户信息(getInfo)
  18. Travis CI(持续集成)
  19. android manifest相关属性
  20. 【技术干货】工业触摸屏之电阻屏原理(连载)

热门文章

  1. SQLAlchemy engine.Engine
  2. 重磅:服务器基础知识全解终极版(145页PPT)
  3. VMware vRealize Operations Manager的内部版本号(2145975)
  4. Java基础学习总结(164)——别让Lombok使你的Java代码处于“亚健康”状态
  5. Mysql学习总结(70)——MySQL 优化实施方案
  6. SVN学习总结(3)——分支合并
  7. Git学习总结(12)——多人开发 Git 分支管理详解
  8. php遍历原理,PHP数组遍历与实现原理
  9. 一个长方体玻璃容器从里面量长宽_在玻璃鱼缸里用微型观叶植物布置景观,比盆景还要迷人...
  10. 宏基因组多少钱一个样_离网式光伏发电系统费用一般是多少钱