19. UIAlertController 提示框获取文本内容,打印控制台上
1.首先定义一个全局字符串变量,方便接收获取的文本内容
2.
-(void)viewDidAppear:(BOOL)animated{
UIAlertController * alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"提示信息" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"点击取消");
}];
UIAlertAction * logIn = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"点击确定%@",_str);
}];
[alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
关键点:倒入代理协议文件,设置代理
textField.delegate=self;
NSLog(@"添加一个textField就会调用 这个block");
}];
[alert addAction:cancel];
[alert addAction:logIn];
[self presentViewController:alert animated:YES completion:nil];
}
3. 调用代理方法
- (void)textFieldDidEndEditing:(UITextField *)textField{
_str=textField.text;
}
4.完美结束
5.补充其其它,创建提示框(直接上代码)
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"显示的标题" message:@"标题的提示信息" preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"点击取消");
}]];
[alertController addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"点击确认");
}]];
[alertController addAction:[UIAlertAction actionWithTitle:@"警告" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"点击警告");
}]];
[alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
NSLog(@"添加一个textField就会调用 这个block");
}];
// 由于它是一个控制器 直接modal出来就好了
[self presentViewController:alertController animated:YES completion:nil];
19. UIAlertController 提示框获取文本内容,打印控制台上的更多相关文章
- 关于java 获取 html select标签 下拉框 option 文本内容 隐藏域
在HTML中从多选下拉框中提取已选中选项的文本内容到后台,被这个问题难倒了. demo.jsp文件 <select id="selecttype" name"typ ...
- java通过URL获取文本内容
原文地址https://www.cnblogs.com/myadmin/p/7634262.html public static String readFileByUrl(String urlStr) ...
- 通过http路径获取文本内容(Java)
public static String readFileByUrl(String urlStr) { String res = null; try { URL url = new URL(urlSt ...
- input文本框自适应文本内容宽度
input文本框自适应文本内容宽度 <!DOCTYPE html> <html> <head> <meta charset="utf-8" ...
- JS中通过id或者class获取文本内容
一.JS通过id获取文本内容 二.JS通过class获取文本内容
- 通过html()的方法获取文本内容, form表单组件显示的值与获取到的值不一致的问题
我在通过 html()获取对应节点的内容,发现一个问题,获取到的 form表单组件的内容值是初始加载的值,而不是经过用户修改后的值.例如页面加载时组件<input type="text ...
- 【Unity笔记】提示框ToolTips大小自适应,及其闪烁的问题
需求:制作了一个提示框,当鼠标移入背包格子内,显示提示框,且提示框位置跟随鼠标移动.当鼠标移出背包格子,隐藏提示框. 制作提示框ToolTips 因为提示框的大小要求随着显示的文本内容长度而自动大小适 ...
- el-tree文本内容过多显示不完全问题(解决)
布局: <span class="custom-tree-node" slot-scope="{ node, data }"> 外层span 树节点 ...
- jq实现百度图片移入移出内容提示框上下左右移动的效果
闲来无聊,看到百度图片hover的时候提示框的效果,遂想试一试自己能否实现. 百度图片hover的效果: 需求: 1. 当鼠标从图片上部移入的时候,提示框从上部移到正常位置.从上部移出的时候,提示框从 ...
随机推荐
- npm库下载缓慢解决方案
淘宝针对国内下载npm库缓慢的问题,使用建立自己的cnpm库,可以很方便使用在公司内部使用. 地址:http://npm.taobao.org/ $ npm install -g cnpm --reg ...
- 照片灰蒙蒙?用PS的曲线功能来解决 (转)
原文地址:http://realjasonc.blog.163.com/blog/static/16475932520107594048957/ 上次,给大家看了几张较为典型的直方图.其实直方图的状态 ...
- nullcon HackIM 2016 -- Crypto Question 5
Now you are one step away from knowing who is that WARRIOR. The Fighter who will decide the fate of ...
- c++继承概念
蠢了3年了,在找工作的今天明白了何为继承……呵呵呵…… 3种继承方式:public.protected.private. 注意几点: 1.继承只能继承基类的public和protected成员 2.3 ...
- Tcc学习笔记(三) 使用举例
TCC的使用以使用第三方库为例子,例子包括:OpenGL , GMP以及SDL等. 1.TCC使用GLUT 去OpenGL下载http://www.opengl.org/resources/libra ...
- js 验证用户名和密码是否为空
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"% ...
- MSSQLSERVER服务无法启动的解决方案
MSSQLSERVER服务无法启动的解决方案 有时候sqlserver无法启动了,原因是mssqlserver服务没有启动,当你手动启动时,又出现服务无法响应的可恶错误提示... 笔者“有幸”遇到了, ...
- JavaScript取得Format后的当前时间
function getNowFormatDate() { var date = new Date(); var seperator1 = "-"; var seperator2 ...
- 【Lua】Lua的几点优化原则
Lua是一门以性能著称的脚本语言,被广泛的应用在很多方面,比如很多游戏的插件. 很多时候,没有必要去考虑性能的问题,不过,如果我们在开始编写代码的时候就以更适当,性能更高的方式与结构去组织代码,对于程 ...
- 根据第三方库spire.pdf使用指定打印机打印pdf文件
private void button1_Click(object sender, EventArgs e) { PdfDocument doc = new PdfDocument(); string ...