UIAlertController中TextField的用法
import UIKitclass ViewController: UIViewController {override func viewDidLoad() {super.viewDidLoad()}override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {// 创建let alertController = UIAlertController(title: "提示", message: "你确定要离开?", preferredStyle:.Alert) // 设置2个UIAlertAction let cancelAction = UIAlertAction(title: "取消", style: .Cancel, handler: nil) let okAction = UIAlertAction(title: "好的", style: .Default) { (UIAlertAction) in print("点击了好的") } // 添加 alertController.addAction(cancelAction) alertController.addAction(okAction) // 弹出 self.presentViewController(alertController, animated: true, completion: nil) } }
- 12
// 除了弹出,还可以使用底部向上滑出的样式// 注意:如果上拉菜单中有『取消』按钮的话,那么它永远都会出现在菜单的底部,不管添加的次序如何// 创建// preferredStyle 为 ActionSheetlet alertController = UIAlertController(title: "保存或删除数据", message: "删除数据将不可恢复", preferredStyle:.ActionSheet) // 设置2个UIAlertAction let cancelAction = UIAlertAction(title: "取消", style: .Cancel, handler: nil) let deleteAction = UIAlertAction(title: "删除", style: .Destructive, handler: nil) let saveAction = UIAlertAction(title: "保存", style: .Default, handler: nil) // 添加到UIAlertController alertController.addAction(cancelAction) alertController.addAction(saveAction) alertController.addAction(deleteAction) // 弹出 self.presentViewController(alertController, animated: true, completion: nil)
/*添加任意数量的文本输入框(比如可以用来实现登录框)*/let alertController = UIAlertController(title: "系统登录", message: "请输入用户名和密码", preferredStyle: UIAlertControllerStyle.Alert)alertController.addTextFieldWithConfigurationHandler { (textField:UITextField) in textField.placeholder = "用户名" } alertController.addTextFieldWithConfigurationHandler { (textField:UITextField) in textField.placeholder = "密码" textField.secureTextEntry = true } let cancelAction = UIAlertAction(title: "取消", style: UIAlertActionStyle.Cancel, handler: nil) let okAction = UIAlertAction(title: "好的", style: UIAlertActionStyle.Default) { (UIAlertAction) in let login = alertController.textFields![0] let pwd = alertController.textFields![1] print("用户名:\(login.text) 密码:\(pwd.text)") } alertController.addAction(cancelAction) alertController.addAction(okAction) // 弹出 self.presentViewController(alertController, animated: true, completion: nil)
UIAlertController中TextField的用法相关推荐
- mysql中change用法,mysql 中alter的用法以及一些步骤
mysql 中alter的用法以及一些方法 在用到alter的时间,查到了这个文章,就copy下来了,详细进入下面链接: MySQL之alter语句用法总结 1:删除列 ALTER TABLE [表名 ...
- mysql中正则表达式的用法_Mysql中正则表达式Regexp常见用法
Mysql中Regexp常见用法 模糊匹配,包含特定字符串 # 查找content字段中包含"车友俱乐部"的记录 select * from club_content where ...
- 【C++】C/C++ 中 static 的用法全局变量与局部变量
C/C++ 中 static 的用法全局变量与局部变量 目录 1. 什么是static? 1.1 static 的引入 1.2 静态数据的存储 2. 在 C/C++ 中static的作用 2.1 总的 ...
- php foreach嵌套foreach,php中foreach怎么嵌套foreach PHP中foreach函数用法?
foreach的使用方法小编不是很明确,分享达人指教一下.foreach (array_expressforeach($array as $key) { if(xxxx) { break; //bre ...
- python中str的index什么意思_python中index的用法是什么
index() 一般用处是在序列中检索参数并返回第一次出现的索引,没找到就会报错,比如:>>> t=tuple('Allen') >>> t ('A', 'l', ...
- php foreach是什么,php中foreach的用法是什么
php中foreach的用法是:[foreach ($array as $value) {要执行代码;}],每进行一次循环,当前数组元素的值就会被赋值给$value变量,在进行下一次循环时,将得到数组 ...
- java中的基本用法
java中的基本用法 关键字:专门用途的字符串 所有java关键字都是小写英文 标识符 java常量 java变量 ■ 作用域:起作用的区域■ 使用前必须先声明,在赋值.使用变量名访问这块区域 jav ...
- Java中getResourceAsStream的用法
Java中getResourceAsStream的用法 首先,Java中的getResourceAsStream有以下几种: 1. Class.getResourceAsStream(String p ...
- javascript 中 console 的用法
javascript 中 console 的用法 视频 https://www.bilibili.com/video/BV1g7411L751?from=search&seid=1567656 ...
- tensorflow中Tensorboard的用法
tensorflow中Tensorboard的用法 下面代码定义了一个简单的用于实现常量加法和乘法的计算图. import tensorflow as tf input1 = tf.constant( ...
最新文章
- pip包管理工具-install执行流程简单查看
- NodeJs教程(介绍总结!)终于在网上找到一个靠谱点的了T_T
- 1.2.1 Logistic回归和梯度下降简介
- python dataframe删除某一列_怎样用Python进行数据分析
- python 文件分割 按大小_python处理分隔大文件
- Mybatis3(3)动态 SQL
- eos 源代码学习笔记一
- centos6.5下安装gradle编译环境
- 克罗谈投资策略03_你所期望的赌博方式
- [C] strncpy 函数
- YII 利用Clip构建layout
- 前端 JavaScript 之『节流』的简单代码实现
- 随机过程(基本概念、平稳随机过程)
- SpringBoot使用Nacos作为配置中心服务和服务注册中心
- 中国情绪识别与分析市场深度研究分析报告
- html把一张图片动态的代码,AI不仅会P图了,还能让照片“动起来”!
- 古风尚婚纱摄影--决定
- 阿里云两分钟一键极速搭建个人网盘
- Scanpy(四)使用ingest和BBKNN整合数据
- 一千度近视眼学计算机,【震惊了】你见过近视8百,1千,3千,5千度?你见过9000度吗?...
热门文章
- atitit.图片相似度与图片查找的设计 获取图片指纹
- paip.声音按键音延迟的解决
- PAIP.SQL的跟踪与调试
- Clickhouse: A股分时线bar数据python实验-批量导入[上]
- 支付那些事儿III---一个BD汪眼中的产品II
- Rust : codewars的Sum of Pairs
- (转)FOF、MOM投资模式与金融科技应用展望
- 阿里云 MSE 微服务治理发布企业版
- 阿里云解决方案架构师徐翔:云上安全建设实战
- 【优化求解】基于matlab遗传算法求解红绿灯管理优化问题【含Matlab源码 262期】