//
//  ViewController.swift
//  alertView
//
//  Created by su on 15/12/7.
//  Copyright © 2015年 tian. All rights reserved.
//

import UIKit

class ViewController: UIViewController {
   
   var controller:UIAlertController!
    override func viewDidLoad() {
//        1.强制对Optional值进行拆包(unwrap)
//        2.声明Implicitly Unwrapped Optionals值,一般用于类中的属性
     
       
        super.viewDidLoad()
         //创建UIAlertController实例
       
        controller = UIAlertController(title: "我是**", message: "爱我的点击确定", preferredStyle: UIAlertControllerStyle.Alert)
       
       
        controller.addTextFieldWithConfigurationHandler { (textFiled:UITextField!) -> Void in
            textFiled.placeholder = "我们都爱Swift"
        }
        //创建action
//                let action = UIAlertAction(title: "确定", style: UIAlertActionStyle.Default) { (paramAction:UIAlertAction!) -> Void in
//                    print("果然是真爱啊")
//                }
        let action = UIAlertAction(title: "确定", style: UIAlertActionStyle.Default) { (paramActoin:UIAlertAction!) -> Void in
            if let textFields = self.controller.textFields {
                let txtFields = textFields as [UITextField]
                let txt = txtFields[0].text
                print("输入的内容是:\(txt)")
               
            }
        }
        //让alertController添加action
        controller.addAction(action)

}

override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        self.presentViewController(controller, animated: true, completion: nil)
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}

 

swift学习之-- UIAlertViewController -alert的更多相关文章

  1. swift 学习之 UIAlertViewController

    // //  PushViewController.swift //  tab // //  Created by su on 15/12/7. //  Copyright © 2015年 tian. ...

  2. swift学习之-- UIAlertVIewController - uiactionsheet

    // //  ViewController.swift //  actionsheet // //  Created by su on 15/12/7. //  Copyright © 2015年 t ...

  3. Swift学习之常用UI的使用

    Swift学习之常用UI的使用 最近笔者在开始学习苹果最新的编程语言,因为笔者认为,苹果既然出了这门语言就绝对不会放弃,除非苹果倒闭了(当然这里知识一个玩笑). 所以在不久的将来,swift绝对是iO ...

  4. swift学习:第一个swift程序

    原文:swift学习:第一个swift程序 最近swift有点火,赶紧跟上学习.于是,个人第一个swift程序诞生了... 新建项目

  5. 【swift学习笔记】二.页面转跳数据回传

    上一篇我们介绍了页面转跳:[swift学习笔记]一.页面转跳的条件判断和传值 这一篇说一下如何把数据回传回父页面,如下图所示,这个例子很简单,只是把传过去的数据加上了"回传"两个字 ...

  6. 今天开始Swift学习

    今天开始Swift学习  在此记录笔记  以备之后查阅! allenhuang

  7. iOS ---Swift学习与复习

    swift中文网 http://www.swiftv.cn http://swifter.tips/ http://objccn.io/ http://www.swiftmi.com/code4swi ...

  8. 12套swift学习资源分享

    虽然objective-c编程语言在过去很长一段时间都是iOS应用开发的基础语言,且很多iOS开发者对其也深爱有佳,但是随着swift编程语言的问世,迅速发展为开发者追捧的语言.且今年伴随着swift ...

  9. [转]swift 学习资源 大集合

    今天看到了一个swift的学习网站,里面收集了很多学习资源 [转自http://blog.csdn.net/sqc3375177/article/details/29206779] Swift 介绍 ...

随机推荐

  1. Centos 6 安装 配置 oracle11g R2

    1.安装centos6.3_64位: 下载地址:http://mirror.bit.edu.cn/centos/6.3/isos/x86_64/ CentOS-6.3-x86_64-bin-DVD1. ...

  2. nginix.conf 中的gzip模块设置

    gizp模块配置 gzip  on;    gzip_min_length  1k;    gzip_buffers     4 16k;    gzip_http_version 1.0;    g ...

  3. [win10]遇坑指南

    好多不好用的地方,现在解决的差不多了,把经验分享一下,也方便自己下一次重装 win10 时不再进坑. 1. 输入法:https://zhidao.baidu.com/question/45942172 ...

  4. libevent源码学习

    怎么快速学习开源库比如libevent? libevent分析 - sparkliang的专栏 - 博客频道 - CSDN.NET Libevent源码分析 - luotuo44的专栏 - 博客频道 ...

  5. F5 源地址保持

    Virtusl Server: Web Portal 建议选择成Source_Addr(源地址保持).因为Web Portal提供WEB服务给用户访问,压力比较大,而源地址保持的方式处理速度比Cook ...

  6. mongodb与SQL常见语句对照

    inert into users value(3,5) db.users.insert({a:3,b:5})     select a,b from users db.users.find({}, { ...

  7. ptthon 网络编程

    网络编程 网络目的 : 数据的传输 网络数据传输是一个复杂的过程 ISO :国际标准化组织 OSI 七层模型 --> 网络通信标准化流程 应用层 : 提供用户服务,具体内容由特定程序规定 表示层 ...

  8. Java 8 : Stream API 练习

    //店铺属性类 public class Property { String name; // 距离,单位:米 Integer distance; // 销量,月售 Integer sales; // ...

  9. php 文件缓存类

    //文件缓存类 class FileCache { private $cacheTime = 3600; //默认缓存时间 秒 private $cacheDir = './filecache'; / ...

  10. 安装MySQL时出现黄色感叹号,提示3306已被占用

    windows系统如何查看现在某个端口的应用进程id呢,命令是: 1.netstat  -aon|findstr 3306 2.最后的那个数值就是进程id号,此时需要查看该id号对应的应用是哪一个,可 ...