- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIButton *alertBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    alertBtn.frame = CGRectMake(40, 100, 295, 30);
    [alertBtn setTitle:@"Show AlertController" forState:UIControlStateNormal];
    [alertBtn addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:alertBtn];
}

- (void)btnClicked:(UIButton *)btn
{
    // UIAlertControllerStyleActionSheet ActionSheet的样式
    // UIAlertControllerStyleAlert       AlertView的样式
    
    //  实例化UIAlertController,这个东西是iOS8才有的
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"这是一个AlertController" message:@"这里是提示的内容" preferredStyle:UIAlertControllerStyleActionSheet];
    
    // 创建3个按钮
    UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"按钮1" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
        
        NSLog(@"点击了按钮1");
    }];
    
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消按钮" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
        
        NSLog(@"点击了取消按钮");
    }];
    
    UIAlertAction *deleteAction = [UIAlertAction actionWithTitle:@"删除按钮" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
        
        NSLog(@"点击了删除按钮");
    }];
    
    // 把按钮添加到AlertController里面
    [alertController addAction:action1];
    [alertController addAction:cancelAction];
    [alertController addAction:deleteAction];
    
    // 显示AlertController,用模式跳转的方式让其显示
    [self presentViewController:alertController animated:YES completion:^{
        
    }];
}

UI第十四节——UIAlertController的更多相关文章

  1. 大白话5分钟带你走进人工智能-第十四节过拟合解决手段L1和L2正则

                                                                               第十四节过拟合解决手段L1和L2正则 第十三节中, ...

  2. 第三百八十四节,Django+Xadmin打造上线标准的在线教育平台—路由映射与静态文件配置以及会员注册

    第三百八十四节,Django+Xadmin打造上线标准的在线教育平台—路由映射与静态文件配置以及会员注册 基于类的路由映射 from django.conf.urls import url, incl ...

  3. 第三百七十四节,Django+Xadmin打造上线标准的在线教育平台—创建课程app,在models.py文件生成4张表,课程表、课程章节表、课程视频表、课程资源表

    第三百七十四节,Django+Xadmin打造上线标准的在线教育平台—创建课程app,在models.py文件生成4张表,课程表.课程章节表.课程视频表.课程资源表 创建名称为app_courses的 ...

  4. 第三百六十四节,Python分布式爬虫打造搜索引擎Scrapy精讲—elasticsearch(搜索引擎)的mapping映射管理

    第三百六十四节,Python分布式爬虫打造搜索引擎Scrapy精讲—elasticsearch(搜索引擎)的mapping映射管理 1.映射(mapping)介绍 映射:创建索引的时候,可以预先定义字 ...

  5. 第三百五十四节,Python分布式爬虫打造搜索引擎Scrapy精讲—数据收集(Stats Collection)

    第三百五十四节,Python分布式爬虫打造搜索引擎Scrapy精讲—数据收集(Stats Collection) Scrapy提供了方便的收集数据的机制.数据以key/value方式存储,值大多是计数 ...

  6. 第三百四十四节,Python分布式爬虫打造搜索引擎Scrapy精讲—craw母版l创建自动爬虫文件—以及 scrapy item loader机制

    第三百四十四节,Python分布式爬虫打造搜索引擎Scrapy精讲—craw母版l创建自动爬虫文件—以及 scrapy item loader机制 用命令创建自动爬虫文件 创建爬虫文件是根据scrap ...

  7. 第三百三十四节,web爬虫讲解2—Scrapy框架爬虫—Scrapy爬取百度新闻,爬取Ajax动态生成的信息

    第三百三十四节,web爬虫讲解2—Scrapy框架爬虫—Scrapy爬取百度新闻,爬取Ajax动态生成的信息 crapy爬取百度新闻,爬取Ajax动态生成的信息,抓取百度新闻首页的新闻rul地址 有多 ...

  8. 第三百二十四节,web爬虫,scrapy模块介绍与使用

    第三百二十四节,web爬虫,scrapy模块介绍与使用 Scrapy是一个为了爬取网站数据,提取结构性数据而编写的应用框架. 其可以应用在数据挖掘,信息处理或存储历史数据等一系列的程序中.其最初是为了 ...

  9. 第三百一十四节,Django框架,自定义分页

    第三百一十四节,Django框架,自定义分页 自定义分页模块 #!/usr/bin/env python #coding:utf-8 from django.utils.safestring impo ...

随机推荐

  1. 【2016-11-7】【坚持学习】【Day22】【Oracle 递归查询】

    直接在oracle 递归查询语句 select * from groups start with id=:DeptId connect by prior superiorid =id 往下找 sele ...

  2. POJ1273Drainage Ditches[最大流]

    Drainage Ditches Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 71559   Accepted: 2784 ...

  3. 脏检查and刷新机构

    ---恢复内容开始--- 脏检查:当食物提交时,Hiberante会对Session中持久状态的对象进行加测,判断对象的数据是否发生了变化 为什么要进行脏检查?, 解析:如果对象发生了改变,就需要将改 ...

  4. bzoj[3238][ahoi差异]

    Description Input 一行,一个字符串S Output 一行,一个整数,表示所求值 Sample Input cacao Sample Output HINT 2<=N<=5 ...

  5. Linux 进程间通讯详解五

    msgrcv函数 ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp,int msgflg); --功能:是从一个消息队列接 ...

  6. LeetCode:3Sum, 3Sum Closest, 4Sum

    3Sum Closest Given an array S of n integers, find three integers in S such that the sum is closest t ...

  7. 《Java程序设计与数据结构教程(第二版)》学习指导

    <Java程序设计与数据结构教程(第二版)>学习指导 欢迎关注"rocedu"微信公众号(手机上长按二维码) 做中教,做中学,实践中共同进步! 原文地址:http:// ...

  8. Yeelink 初探

    Yeelink可以作为中转服务器使用,在自己没有服务器的情况下,可以利用它传输自己的数据. 首先去申请一个帐号,然后添加一个设备. http://www.yeelink.net/user 在这里是用户 ...

  9. asp.net MVC 通用登录验证模块

    用法: 还是希望读者把源码看懂,即可运用自如.重点是,为什么有个UserType!!! 登录用户信息: namespace MVCCommonAuth { [Serializable] public ...

  10. 随便写一下看下效果。一个js问题

    (function(a){ console.log(a); var a = 10; function a(){} }(100)); 问:执行这段代码会输出什么.