UIAlertView以及UIAlertController
来源:互联网 发布:社交网络电影百度网盘 编辑:程序博客网 时间:2024/06/06 07:42
UIAlertView 是iOS2.0之后就出现的。在8.0后逐渐被废除,但现在还是可以使用的。
UIAlertView *alertView = [[UIAlertViewalloc] initWithTitle:@“标题”
message:@“警示内容”
delegate:selfcancelButtonTitle:@"确定"
otherButtonTitles:@"取消",nil];
[alertView setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];
//下面的两个textFielder根据alert的类型来进行是否设置。否则数组越界崩溃。
UITextField *text=[alertView textFieldAtIndex:0];
text.clearButtonMode=UITextFieldViewModeAlways;
text.placeholder=@"哇哈哈";
//
UITextField *text1=[alertView textFieldAtIndex:1];
text1.clearButtonMode=UITextFieldViewModeAlways;
text1.placeholder=@"哇哈哈";
[alertViewshow];
UIAlertControoler 是iOS 8.0之后出现的新技能。
UIAlertControoler可以做出UIAlertView 和 UIActionSheet
融合了二者而来。
UIAlertController中的UIAlertView实现
UIAlertController *alert = [UIAlertControlleralertControllerWithTitle:@"警告"message:@"发生了什么"preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *action = [UIAlertActionactionWithTitle:@"警告"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction *action) {
//按钮被点击
NSLog(@"action click");
}];
[alert addAction:action];
[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = @"姓名";
}];
[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = @"年龄";
}];
[selfpresentViewController:alert animated:YEScompletion:^{
}];
UIAlertController中UIActionSheet实现
UIAlertController *alertAct = [UIAlertControlleralertControllerWithTitle:@"警告"message:@"发生了什么"preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *aaa = [UIAlertActionactionWithTitle:@"1"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction *action) {
NSLog(@"action sheet click 1");
}];
[alertActaddAction:aaa];
[alertAct addAction:[UIAlertActionactionWithTitle:@"2"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction *action) {
NSLog(@"action sheet click 2");
}]];
[selfpresentViewController:alertAct animated:YEScompletion:^{
}];
- UIAlertView以及UIAlertController
- iOS8 UIAlertController 创建UIAlertView以及UIActionSheet
- UIAlertController的用法以及和其与UIAlertView的区别
- UIAlertView 和UIAlertController二合一
- UIAlertView变成了UIAlertController
- UIAlertView 和 UIAlertController
- UIAlertController与 UIAlertView
- UIAlertController(UIActionSheet、UIAlertView)
- 浅谈UIAlertView与UIAlertController
- UIAlertController & UIAlertView 对话框
- UIAlertController UIAlertAction (UIAlertView, UIActionSheet)
- UIAlertController和UIAlertView
- UIAlertController代替UIAlertView
- UIAlertController(UIAlertView && UIActionSheet)
- 浅谈UIAlertView与UIAlertController
- UIAlertView与UIAlertController
- 替换UIAlertView、UIAlertController
- UIAlertController 和 UIAlertView的使用
- java中synchronized的用法与详解
- 要事为先
- 关于Class.getResource和ClassLoader.getResource的路径问题
- 周记:适配心得
- 在centos6.5上安装docker
- UIAlertView以及UIAlertController
- 国外文凭制作中心/制作国外毕业证/国外文凭QQ:122157333
- 新版FFmpeg音频编解码处理
- IOS开发系列--GCD详解介绍
- 数据结构与算法11: 伸展树(SplayTree)
- poj2987最大权闭包(输出最少建塔个数)
- Java 对日期的操作
- Centos编译安装 LAMP (apache-2.4.7 + mysql-5.5.35 + php 5.5.8)+ Redis
- 终极童颜,属于你的任性资本!美容师培训,美容美发培训学校