ios 9.0以后关于UIAlertView和 UIActionSheet使用的一些新的变化
来源:互联网 发布:无线办公鼠标推荐知乎 编辑:程序博客网 时间:2024/06/07 11:23
IOS UIAlertController 弹框 (ios 9.0 后代替了UIAlertView弹框 和 UIActionSheet下弹框)
在IOS 9.0 后 苹果官方宣布不再或不推荐使用UIAlertView 和 UIActionSheet 由UIAlertController进行代替两者 用控制器将两者合二为一 很简单 方便 下面就是关于UIAlertView的常用方法
#import "RootViewController.h"@interface RootViewController ()@end@implementation RootViewController- (void)viewDidLoad { [super viewDidLoad]; // 创建一个BUTTON 点击显示弹框 UIButton *button = [UIButton buttonWithType:(UIButtonTypeCustom)]; button.frame = CGRectMake(100, 100, 100, 100); // 给BUTTON 添加点击方法 [button addTarget:self action:@selector(actionButton:) forControlEvents:(UIControlEventTouchUpInside)]; button.backgroundColor = [UIColor blueColor]; [self.view addSubview:button];}// button的点击方法- (void)actionButton:(UIButton *)button{ // 初始化一个一个UIAlertController // 参数preferredStyle:是IAlertController的样式 // UIAlertControllerStyleAlert 创建出来相当于UIAlertView // UIAlertControllerStyleActionSheet 创建出来相当于 UIActionSheet UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"静" preferredStyle:(UIAlertControllerStyleAlert)]; // 创建按钮 UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction *action) { NSLog(@"注意学习"); }]; // 创建按钮 // 注意取消按钮只能添加一个 UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleCancel) handler:^(UIAlertAction *action) { // 点击按钮后的方法直接在这里面写 NSLog(@"注意学习"); }];// // 创建警告按钮// UIAlertAction *structlAction = [UIAlertAction actionWithTitle:@"警告" style:(UIAlertActionStyleDestructive) handler:^(UIAlertAction *action) {// NSLog(@"注意学习");// }];// // 添加按钮 将按钮添加到UIAlertController对象上 [alertController addAction:okAction]; [alertController addAction:cancelAction]; //[alertController addAction:structlAction]; // 只有在alert情况下才可以添加文本框 [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) { textField.placeholder = @"用户名"; textField.secureTextEntry = YES; }];// // 取出文本// UITextField *text = alertController.textFields.firstObject;// UIAlertAction *action = alertController.actions.firstObject; // 将UIAlertController模态出来 相当于UIAlertView show 的方法 [self presentViewController:alertController animated:YES completion:nil];}
0 0
- ios 9.0以后关于UIAlertView和 UIActionSheet使用的一些新的变化
- iOS学习笔记—— UIAlertView 和 UIActionSheet 的使用
- iOS8.0 之后UIAlertView和UIActionSheet的创建方式的新变化
- iOS8.0 之后UIAlertView和UIActionSheet的创建方式的新变化
- UIAlertView,UIActionSheet的使用
- iOS UIAlertView和UIActionSheet的用法
- UIAlertView和UIActionSheet类在IOS8以后的改动
- UIAlertView提示控件和UIActionSheet的使用
- iOS8 UIAlertView 和 UIActionSheet 的新用法 UIAlertController详解
- ios 关于UIAlertView与UIActionSheet的区别,以及在使用过程中注意事项
- IOS-UIAlertView和UIActionSheet
- iOS 8 引入的 UIActionSheet 和 UIAlertView 的替代品 - UIAlertController
- IOS开发之 ---- iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一)
- IOS开发之 ---- iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一)
- IOS开发之 ---- iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一)
- iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet)
- 介绍UIALertView和UIActionSheet的用法。
- 介绍UIALertView和UIActionSheet的用法。
- C++用类链表模仿栈操作
- 欢迎使用CSDN-markdown编辑器
- 工具类- 身份证校验
- RecyclerView's Note
- 整合SSH java.lang.ClassCastException: xxx_$$_javassist_0 cannot be cast to javassist.util.proxy.Proxy
- ios 9.0以后关于UIAlertView和 UIActionSheet使用的一些新的变化
- 蓝桥杯算法—— 算法训练 前缀表达式
- linux下cat命令详解
- Cocoapods安装步骤(OS X 10.11环境)
- LeetCode-236.Lowest Common Ancestor of a Binary Tree
- Solr数据不同步
- ceph存储 Linux direct io使用
- ZOJ 3778Talented Chef-二分/规律
- class org.apache.commons.dbcp.basicdatasource not found解决办法