//
//  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. Shell实现Unix进程间信息交换的几种方法

    本文将介绍在SCO OpenServer5.0.5系统中使用shell语言来实现进程间信息交换的几种方法: 使用命名管道实现进程间信息交换 使用kill命令和trap语句实现进程间信息交换 使用点命令 ...

  2. 02 - Unit04:笔记本加载功能

    @ExceptionHandler 在控制器中统一处理异常. 为了重用异常处理方法,可以将处理方法抽象到父类中,子类共享异常处理方法. 语法: @ExceptionHandler(Exception. ...

  3. IDA python使用笔记

    pattern='20 E5 40 00' addr=MinEA() for x in range(0,5):     addr=idc.FindBinary(addr,SEARCH_DOWN,pat ...

  4. 认识Linux操作系统

    Linux系统是一个类似UNIX的操作系统 认识Linux的来世与今生 1.Linux系统的历史 Linux系统是一个类似UNIX的操作系统,Linux系统是UNIX在微机上的完整实现,它的标志是一个 ...

  5. 在Windows命令行窗口中输入并运行PHP代码片段(不需要php文件)的方法

    有时候只是简单的为了测试某个php函数的效果,以前总是需要建一个php文件,复制这个文件的路径,再通过web访问或者用php命令执行这个php文件. 一直想要怎么才能不用创建文件,才能直接执行PHP代 ...

  6. win10 svn commit无响应

    只是发现其中的一个原因,发现.cs代码文件图标变红了,默认是用Code Writer打开,和SVN可能是冲突了,解决方式是用Code Writer打开一下.cs文件就可以了,原因可能是不打开一次Cod ...

  7. win10初期版本administrator的限制

    win10初期版本administrator的限制,很多功能administrator用户无法使用如应用商店等等,在目前的新版本,差不多都可以使用了.

  8. RabbitMQ 信道(channel)挂掉,但连接仍然存在,同时出现错误:Received remote Channel.Close (406): PRECONDITION_FAILED - unknown delivery tag x 的问题

    该问题经过一番试验,发现是消费者(consumer)程序逻辑错误导致:在消息处理的回调函数中多次ack或nack. 开启Python日志,并在回调函数中两次ack得到如下信息: F:\software ...

  9. 关于sqoop --split-by 及 -m的理解

    场景: sqoop import --connect jdbc:postgresql://...../..... --username ....  --query "select * fro ...

  10. xml 注释中不允许出现字符串“--“(再也不要来坑爹了,好么,XML)

    转自:https://blog.csdn.net/randomnet/article/details/18708575?utm_source=blogxgwz3 关于xml文件时出现中文注释出错的一个 ...