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. 当鼠标从图片上部移入的时候,提示框从上部移到正常位置.从上部移出的时候,提示框从 ...
随机推荐
- egrep 及扩展正则表达式
grep -E 表示支持扩展的正则表达式 grep -E = egrep 一.字符匹配: 扩展模式下的字符匹配与基本正则表达式的字符匹配相同,如: . 表示任意单个字符 [] 表示范围内人任意单个字符 ...
- EntityFramework+MySql 笔记1
最近需要使用mysql ,而之前用惯了EF,所以就尝试EntityFramework+MySql的方案. 首先上网搜了一大通资料后,这样开始: 安装mysql,我用的版本是5.6.25 ( windo ...
- Excel 读写程序 C#源代码下载
http://u.163.com/lNaJAjOz 提取码: E4ZHjnfD
- php多条件搜索
PHP多条件查询 December : Tuesdayby 小屋 在我们的网站设计过程中,经常会用到多条件查询,本文的源码是一个二手房屋查询的例子.在本例中,我们要实现能够通过地理位置,物业类型,房屋 ...
- textview 弹出键盘上面添加完成按钮,并设置输入内容的格式。
- (void)setContentView{ self.contentTextView = [[UITextView alloc]initWithFrame:CGRectMake(11, 70, S ...
- iOS调试
iOS高效调试 写代码难免出现bug.储备些调试技能绝对能够提高你的工作效率,让bug无所遁形.下面就和大家分享一些我在工作中常用的iOS调试小技能. 1. 打印 最简单,基础的调试方法就是打印日志了 ...
- C#窗体文件的操作
文件的创建使用File类下的AppendAllText("要保存的数据","文件完整路径")方法. string fileMove = @"C:\te ...
- nullcon HackIM 2016 -- Programming Question 5
Dont blink your Eyes, you might miss it. But the fatigue and exhaustion rules out any logic, any wil ...
- IE6/IE7/IE8兼容H5标签
可以使用html5shiv(html5shiv主要解决HTML5提出的新元素不被IE6-8识别,这些新元素不能作为父节点包裹子元素,并且不能应用CSS样式)来解决 <!--[if lt IE 9 ...
- ABP mapto 映射
obj1.MapTo(obj2); obj1=>obj2: 在obj1实体里添加映射 [AutoMap(typeof(obj2))] public class obj1 { }