// 将UIAlertController模态出来 相当于UIAlertView show 的方法// 初始化一个一个UIAlertController
    // 参数preferredStyle:是IAlertController的样式
    // UIAlertControllerStyleAlert 创建出来相当于UIAlertView
    // UIAlertControllerStyleActionSheet 创建出来相当于 UIActionSheet
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"调课通知将发给选定同学" preferredStyle:(UIAlertControllerStyleAlert)];
    
    // 创建按钮
    UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction *action) {
        [self.navigationController popViewControllerAnimated:YES];
    }];
    // 创建按钮
    // 注意取消按钮只能添加一个
    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;
    

    [self presentViewController:alertController animated:YES completion:nil];

UIAlertController使用的更多相关文章

  1. UIAlertController

    楼主在整理项目的警告,于是乎你懂的. 然后自己整理了一下以后方便自己忘了之后能及时找到它 关于UIAlertController .h文件的解析 /** 关于UIAlertController的解析 ...

  2. iOS UIAlertController跟AlertView用法一样 && otherButtonTitles:(nullable NSString *)otherButtonTitles, ... 写法

    今天写弹出框UIAlertController,用alertView习惯了,所以封装了一下,跟alertView用法一样,不说了,直接上代码: 先来了解一下otherButtonTitles:(nul ...

  3. IOS UIAlertController 使用方法

    在很多种语言中,alert都表示弹窗操作,弹窗功能非常有用,不仅可以用于正式的app功能中,也可以在调试中使用.在OC中,UIAlertController类用来控制弹窗操作.在IOS 8.0之前, ...

  4. UI控件(UIAlertController)

    @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; UIButton *_button = [UIBut ...

  5. UIAlertController 部分用法及属性

    //创建UIAlertController:初始化UIAlertController 需要使用alertControllerWithTitle UIAlertController *alertCont ...

  6. iOS--UIAlertView与UIAlertController和UIAlertAction之间的事儿

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

  7. 开始使用 UIAlertController 吧

    UIAlertView 与 UIActionSheet UIAlertView 样式 实现 - (void)showAlertView { self.alertView = [[UIAlertView ...

  8. UI第十四节——UIAlertController

    - (void)viewDidLoad {    [super viewDidLoad];        UIButton *alertBtn = [UIButton buttonWithType:U ...

  9. iOS 8.0后使用UIAlertController

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

随机推荐

  1. linux安装nexus

    一.下载nexus 最新地址在:https://www.sonatype.com/download-oss-sonatype 我下载的是:nexus-2.14.1-01-bundle.tar.gz,是 ...

  2. TableView 滑动收起键盘

    self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag; 拖拽tableView就会收起键盘

  3. 解决SmartGit序列号问题

    SmartGit过了30天试用期之后,就需要用户输入序列号才能继续使用,有一个办法可以跳过输入序列号. 一.windows+R  输入:%APPDATA%\syntevo\SmartGit 二.打开7 ...

  4. Spring-----定时任务Quartz配置之手动设置

    一 配置xml如下: <!-- 定时任务配置 --> <bean id="scheduler" class="org.springframework.s ...

  5. js cookie

    cookie:cookis:储存数据,当用户访问了某个网站的时候,我们就可以通过cookie来向访问者电脑上储存数据1)不同浏览器的存放cookie位置不一样,也是不能通用的2)cookie的存储是以 ...

  6. iOS 判断网络连接状态的几种方法

    p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px "PingFang SC"; color: #801b80 } p.p2 ...

  7. SpringMVC学习记录2

    废话 最近在看SpringMVC...里面东西好多...反正东看一点西看一点吧... 分享一下最近的一些心得..是关于DispatcherServlet的 DispatcherServlet与Cont ...

  8. 3MyBatis配置--深入浅出MyBatis技术原理与实践(笔记)

    XML 映射配置文件 configuration 配置 properties 属性 settings 设置 typeAliases 类型命名 typeHandlers 类型处理器 objectFact ...

  9. C(C++)/ 数据结构 链表

    内容概括: 一.链表简介及创建列表 二.添加节点 三.链表排序 代码编译平台: CentOS 6.4 64b 一.链表简介及创建列表: 传统数组缺点: 传统数组长度需要事先设定,不能改变,内存由系统自 ...

  10. leetcode--Different Ways to Add Parentheses

    题目链接:https://leetcode.com/submissions/detail/86532557/ 算法类型:分治法 题目分析:计算表达式的所有结果可能性 代码实现: class Solut ...