alertview和alertviewcontroller的关系
来源:互联网 发布:linux 10秒后关机 编辑:程序博客网 时间:2024/05/16 11:53
在alertview在ios7.0之后就苹果不提倡用,随后就出现了AlertViewController。
本来也是不知道的,但直到公司的大哥跟我说之后,才知道AlertViewController。
首先先来谈谈,Alertview一般是用于警告提示,初始化方法为此
- (instancetype)initWithTitle:(NSString *)title message:(NSString*)message delegate:(id /*<UIAlertViewDelegate>*/)delegate cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ...;
这个方法通过设置一个title,message,delegate,一些按钮的标题创建警告框,代码提示如下
UIAlertview *alert = [【UIAlertview alloc】initwithtitle:@"提示" message:@"这是一个提示框" delegate:self cancelbuttontitle:@“确定” otherbuttontitle:@"确定",nil];
【alert show】;
这样就显现出来啦
大体说挺好用的,但可惜呀在ios9.0 不能用了,而且我也不知道它的按钮添加方法怎么写,无法实现真正的高度自定义
所alertcontroller应运而生
代码如下:UIalertcontroller *alert = 【uialertcontroller alertcontrollerwithtitle:title message:message preferredstyle:uialertcontrllerstylealert】;
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:cancelButtonTitle style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { NSLog(@"The \"Okay/Cancel\" alert's cancel action occured."); }]; UIAlertAction *otherAction = [UIAlertAction actionWithTitle:otherButtonTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { NSLog(@"The \"Okay/Cancel\" alert's other action occured."); }]; // Add the actions. [alertController addAction:cancelAction]; [alertController addAction:otherAction]; [self presentViewController:alertController animated:YES completion:nil];}
就是自定义一个controller在里面按钮啦,在按钮的block方法里添加方法
再写方法,add到alert controller里,present显示出来就行了
额大概就学了这些,一般够用了
0 0
- alertview和alertviewcontroller的关系
- 很全的AlartView和AlertViewController用法
- AlertViewController的使用
- AlertViewController
- Actionsheet和AlertView的使用
- ActionSheet和AlertView的封装
- alertView中的属性和方法的讲解
- iOS7兼容自定义带动画的AlertViewController
- alertView的一些建议
- ios8 新的AlertView
- AlertView的基本用法
- 简单的自定义AlertView
- alertView的简单封装
- AlertView
- alertview
- alertView
- IOS8 alertView 和 actionSheet 使用方法
- 信息提醒:AlertView和UIAlertController
- UIBarButtonSystemItem 样式 和 图片
- javascript 前端验证 file 上传图片 尺寸 大小
- MTK8321 GPS无法校准
- 为啥要用kmp算法,有什么依据嘛
- 简单App项目的运行
- alertview和alertviewcontroller的关系
- Notification版本更替
- Fragment使用方法总结
- 自定义控件 创建复合控件
- js获取窗口大小
- 南京理工大学第八届程序设计大赛(校外镜像) Fsequence
- 新版mac系统CocoaPods安装
- c中变量存储位置分析
- 判定链表是否有环