UIAlertController的写法

UIAlertController的写法

by 伍雪颖

@IBAction func showAlert(sender: AnyObject) {
        let alertController = UIAlertController(title: "Default Style", message: "A standard alert.", preferredStyle: .Alert)

        let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel) { (action) in

        }
        alertController.addAction(cancelAction)

        let destroyAction = UIAlertAction(title: "Destroy", style: .Destructive) { (action) in
            println(action)
        }
        alertController.addAction(destroyAction)

        let OKAction = UIAlertAction(title: "OK", style: .Default) { (action) in

        }
        alertController.addAction(OKAction)

        self.presentViewController(alertController, animated: true) {

        }
    }
时间: 2024-12-24 20:07:18

UIAlertController的写法的相关文章

UIAlertView/UIAlertController封装使用

基于UIAlertView封装的JXTAlertView,这个是将之前写Demo时搞的一套快捷使用alertView的工具抽离整理出来的,并提供了C函数直接调用,像这样: jxt_showAlertTitle(@"简易调试使用alert,单按钮,标题默认为"确定""); 就可以直接显示出一个alertView. 基于UIAlertController封装的JXTAlertController,支持iOS8及以上.调用方式为UIViewController的扩展分类方

IOS UIAlertController 使用方法

在很多种语言中,alert都表示弹窗操作,弹窗功能非常有用,不仅可以用于正式的app功能中,也可以在调试中使用.在OC中,UIAlertController类用来控制弹窗操作.在IOS 8.0之前, 其使用UIAlertView类来控制弹窗,如果我们想弹出一个带有输入框的窗口,可以使用如下的代码: // Prior to iOS 8.0 UIAlertView *alert = [[UIAlertView init] initWithTitle:@"Alert Title" messa

在iOS8.0之后的UIAlertView和UIActionSheet的新写法

在iOS8.0之后,苹果更新了UIAlertView和UIActionSheet的创建方法.在以前的版本中,这两个提醒用户的控件各自有自己的创建方法,但是在iOS8.0之后,使用了UIAlertController这个控制器类统一创建.不过之前的创建方法并没有在iOS8.0之后的版本中实效,依然可以正常使用.下边就记录下新的写法. 首先看苹果API的示例写法: UIAlertController* alert = [UIAlertController alertControllerWithTit

一维数组的三种写法

/** *一维 数组的几种写法 * 记住:①数组的左边不能有数字 *   ②数组的右边既然初始化了数组,那么就要赋值 */ //一维数组的标准格式 String[] arr1 = new String[]{"bo","li","jian"}; //上面的简写格式 String[] arr2 = {"bo","li","jian"}; //初始化容量 String[] arr3 = new

优雅的css写法

一.利用好代码折叠 css也可以进行优雅的代码折叠而且会比html更好看 折叠后的效果: 这样就可以很舒服的把它折叠起来. 二.向Twitter Bootstrap学习 1. 学习的第一点就是用class,去减少id.当然这是一个很基本的知识. 2. 学习的第二点是命名的词汇. 如group.control.banner.list.item,title.panel.content.container这些表结构和关系的词汇: 还有一些形容词danger.primary.lg.xs.info等等:

awk支持多个记录分隔符的写法

awk的-F参数可以指定新的记录分隔符,有些时候可能需求指定多个分隔符,比如下面的内容 width:720 height:360 如果需要取出width和height后面的值的话,一般大家会这样做,即做两次awk操作 # echo "width:720 height:360" | awk '{print $1;print $2}' | awk -F: '{print $2}' 720 360 其实呢,通过在awk中指定两个记录分隔符(空格和:),即可一次性的提取出width和heigh

转:Nginx 配置 location 总结及 rewrite 规则写法

转: http://www.linuxidc.com/Linux/2015-06/119398.htm 1. location正则写法 一个示例: location =/{ # 精确匹配 / ,主机名后面不能带任何字符串 [ configuration A ] } location /{ # 因为所有的地址都以 / 开头,所以这条规则将匹配到所有请求 # 但是正则和最长字符串会优先匹配 [ configuration B ] } location /documents/{ # 匹配任何以 /do

C++ String 深拷贝(传统写法+现代写法)

//C++String 类的常规写法   #include <iostream> using namespace std; class String { public:  //构造函数  String(char*str = "")                 :_str(new char[strlen(str) + 1])  {   strcpy(_str, str);  }  //拷贝构造  String(const String &s)  {   _str 

iOS关于UITabView和UIAlertController,UIAlertAction以及UINavigation,值修改的传递页面推送

关于UITabView和UIAlertController,UIAlertAction以及UINavigation,值修改的传递 集合嵌套集合的操作 声明 两个必须的的代理 实现部分代码 - (void)viewDidLoad { [super viewDidLoad]; // 创建一个TabView self.tabv = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStyleGrouped]; sel