UIAlertController的使用——创建提示窗口
来源:互联网 发布:wifi信号搜索软件 编辑:程序博客网 时间:2024/06/06 01:26
UIAlertController只能在iOS8以上使用,所以要慎用。
在iOS8中,UIAlertController在功能上是和UIAlertView以及UIActionSheet相同的,UIAlertController以一种模块化替换的方式来代替这两货的功能和作用。是使用对话框(alert)还是使用上拉菜单(action sheet),就取决于在创建控制器时,您是如何设置首选样式的。(其实宝宝们心里都知道)
- (void)viewDidLoad {
[superviewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//创建按钮
UIButton *bt=[UIButtonbuttonWithType:UIButtonTypeCustom];
bt.frame =CGRectMake(50,50, 100, 50);
[bt addTarget:selfaction:@selector(bt)forControlEvents:UIControlEventTouchDown];
[bt setBackgroundColor:[UIColorcyanColor]];
[self.viewaddSubview:bt];
[self.viewsetBackgroundColor:[UIColoryellowColor]];
}
//按钮的点击事件
-(void)bt
{
//UIAlertController在功能上是和UIAlertView以及UIActionSheet相同的,UIAlertController以一种模块化替换的方式来代替这两货的功能和作用。是使用对话框(alert)还是使用上拉菜单(action sheet),就取决于在创建控制器时,您是如何设置首选样式的。
//常规(default)、取消(cancel)以及警示(destruective
#pragma mark - 对话框
NSString *title = @"注意";
NSString *message = @"姓名和电话";
// NSString *cancelButtonTitle = @"Cancel";
NSString *otherButtonTitle = @"确定";
NSString *bbTitle=@"xx";
//
UIAlertController *alertController = [UIAlertControlleralertControllerWithTitle:title message:messagepreferredStyle:UIAlertControllerStyleAlert];
// // UIAlertAction *cancel = [UIAlertAction actionWithTitle:cancelButtonTitle style:UIAlertActionStyleCancel handler:nil];
UIAlertAction *otherA = [UIAlertActionactionWithTitle:otherButtonTitle style:UIAlertActionStyleDefaulthandler:nil];
UIAlertAction *action=[UIAlertActionactionWithTitle:bbTitle style:UIAlertActionStyleDefaulthandler:nil];
// //[alertController addAction:cancel];
UIAlertAction *cancelAction = [UIAlertActionactionWithTitle:@"取消"style:UIAlertActionStyleCancelhandler:^(UIAlertAction *aa){
NSLog(@"取消");
}];
UIAlertAction *okAction = [UIAlertActionactionWithTitle:@"好的"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction *action) {
NSLog(@"好的");
}];
//带输入框的文本对话框
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField){
textField.placeholder = @"账号";
}];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = @"密码";
textField.secureTextEntry = YES;
}];
//将创建的按钮添加到控制器上
[alertController addAction:cancelAction];
[alertController addAction:okAction];
[alertController addAction:otherA];
[alertController addAction:action];
[selfpresentViewController:alertController animated:YEScompletion:nil];
#pragma mark - 上拉菜单
UIAlertController *alertController=[UIAlertControlleralertControllerWithTitle:@"标题"message:@"默认"preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *cancelAction=[UIAlertActionactionWithTitle:@"取消"style:UIAlertActionStyleCancelhandler:nil];
UIAlertAction *okAction=[UIAlertActionactionWithTitle:@"确定"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction *action){
NSLog(@"ok");
}];
[alertController addAction:cancelAction];
[alertController addAction:okAction];
[selfpresentViewController:alertController animated:YEScompletion:nil];
- UIAlertController的使用——创建提示窗口
- UIAlertController 的创建和使用
- iOS8统一的系统提示控件——UIAlertController
- iOS8统一的系统提示控件——UIAlertController
- iOS8统一的系统提示控件——UIAlertController
- iOS开发 UIAlertController的创建与使用
- 提示框的使用->UIAlertController类的使用
- iOS -iOS9中提示框(UIAlertController)的常见使用
- iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet)
- IOS8新特性之——UIAlertController的使用
- ios中UIAlertController的使用创建对话框、操作表
- UIAlertController的使用(Swift)
- UIAlertController的使用示例
- UIAlertController的使用二
- UIAlertController的使用
- UIAlertController的使用
- 关于UIAlertController的使用
- UIAlertController的使用
- 时间复杂度的计算<一>
- How can I limit the CPU load and bandwidth when make a video call?
- 在线学习好去处 在线终端 在线IDE
- 11 绘制雪花动态图
- Volley框架之使用GET或POST将cookie传给服务器
- UIAlertController的使用——创建提示窗口
- 一小段代码看内存
- jQuery Ajax 简单的实现跨域请求
- 如何制作一款像超级玛丽兄弟一样基于平台的游戏
- 机器学习与深度学习资料
- HOJ 1444 Humble Numbers
- Delphi 调试
- 【Linux/OS/Network】XSI IPC(消息队列,信号量,共享内存)
- PHP curl 上传文件版本兼容问题