iOS----------UITextField实现过滤选中状态拼音
2018年上班的第二天,就这样背了一个大锅。我们项目中有一个搜索功能,在这一期的版本中,为了增强优化,去除了过滤空格的请求,这样或许能增加很好的用户体验,恰恰相反,偷鸡不成蚀把米。没想到苹果系统的输入法竟然能自动联想,在没有选择汉字的时候,竟然能联想出来一大堆智能拼音,what???还有这种操作????输就输在了我几乎不使用苹果系统的输入法,我的手机设置一般都是把苹果的输入法删除了,直接使用搜狗。(苹果系统的输入法太难用了)不过对于测试人员来说,一定要测试各个系统的输入法,切记!切记!切记!
那现在就看一下没有屏蔽拼音之前的输入内容吧
当我输入蓝海的时候 还没有选择汉字呢 系统就会自动拼接一些拼音。


对比所打印的内容,有没有觉得很惊喜? 怎么样才能把拼音去除掉呢? 给输入框添加一个事件,在事件里面过滤掉拼音 不信你可以试一下。
_searchTextField = [[UITextField alloc]initWithFrame:CGRectMake(20, 100, kScreenWidth-40, 50)];
_searchTextField.delegate = self;
_searchTextField.backgroundColor = [UIColor orangeColor];
_searchTextField.placeholder = @"输入基金,快速定位";
_searchTextField.returnKeyType = UIReturnKeyDone;
_searchTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
[_searchTextField addTarget:self action:@selector(searchTextFieldChanges:) forControlEvents:UIControlEventEditingChanged];
[self.view addSubview:_searchTextField];
- (void)searchTextFieldChanges:(UITextField *)textField{
if (textField.markedTextRange == nil) {
NSLog(@"选中了汉字之后出现的汉字:%@", textField.text);
}
}
iOS----------UITextField实现过滤选中状态拼音的更多相关文章
- UITextField实现过滤选中状态拼音
先提供下简书地址, 排版更好. 我的简书地址: http://www.jianshu.com/p/80e79c6d1511 UITextField相信很多的iOS开发者都会经常用到, 最近项目中遇到了 ...
- IOS中tableView每组的头部控件、通过tableView的代理方法控制某一行的cell能否达到高亮选中状态
一.tableView每组的头部控件 1.控件宽度默认就是tableView的宽度 2.控件高度由下面的代理方法决定 - (CGFloat)tableView:(UITableView *)table ...
- 实现CheckBox的三种选中状态(全选、半选、不选)在GridView中模拟树形的功能
度娘了很多帖子,只说三种状态要用图片替换来做,但没找到有用的例子,被逼自己写了一个 三方控件肯定是很多的,如jstree,可以直接用 由于公司的UDS限制,不能上传图片,只能文字说明了. 就是要在gr ...
- 浅析:点击父控件时,子控件中的textview自动进入选中状态
原因:父控件属性android:clickable="true",而textview之类的自控件默认不可点击,没有独立的点击监听,这样选中父控件时,textview之类的子控件也进 ...
- CheckBox 半选中状态
<input type='checkbox' />可以半选中,这个特性,很多浏览器都支持,包括Firefox,Chrome和IE 用 input.indeterminate 这个属性来获取 ...
- select 和 radio 的选中状态
radio: <script type="text/javascript"> //判断个函数 以上 5 个Radio 那个为选中状态function judgeRadi ...
- 获取select标签选中状态 的label的值。
<select name="procode" onchange="alert(this.options[this.selectedIndex].text)" ...
- cell选中后进入重用池出来选中状态消失
#import "XXViewController.h" @interface XXViewController ()<UITableViewDelegate,UITable ...
- C# mvc DropDownList选中状态无效情况分析
情况: DropDownList控件使用List<SelectListItem>()设置下拉选项和默认值.当控件的Name和后台的ViewBag(或ViewData)的Key重复,会导致选 ...
随机推荐
- 【RL-TCPnet网络教程】第35章 FTP文件传输协议基础知识
第35章 FTP文件传输协议基础知识 本章节为大家讲解FTP(File Transfer Protocol,文件传输协议)的基础知识,方便后面章节的实战操作. (本章的知识点主要整理自网络) ...
- [Swift]LeetCode304. 二维区域和检索 - 矩阵不可变 | Range Sum Query 2D - Immutable
Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper lef ...
- [Swift]LeetCode350. 两个数组的交集 II | Intersection of Two Arrays II
Given two arrays, write a function to compute their intersection. Example 1: Input: nums1 = [1,2,2,1 ...
- [Swift]LeetCode700. 二叉搜索树中的搜索 | Search in a Binary Search Tree
Given the root node of a binary search tree (BST) and a value. You need to find the node in the BST ...
- [Swift]LeetCode773. 滑动谜题 | Sliding Puzzle
On a 2x3 board, there are 5 tiles represented by the integers 1 through 5, and an empty square repre ...
- [Swift]LeetCode805. 数组的均值分割 | Split Array With Same Average
In a given integer array A, we must move every element of A to either list B or list C. (B and C ini ...
- [Swift]LeetCode988. 从叶结点开始的最小字符串 | Smallest String Starting From Leaf
Given the root of a binary tree, each node has a value from 0 to 25 representing the letters 'a' to ...
- 面试官:说说一条查询sql的执行流程和底层原理?
一条查询SQL执行流程图如下 序章 自我介绍 我是一条sql,就是一条长长的字符串,不要问我长什么样,因为我比较傲娇. 额~~不是我不说啊,因为细说起来,我可以细分为DML(Update.Insert ...
- Linux查找文件内容
从当前目录递归查找文件名为 .py 中包含 conf 的文件名: find -name "*.py" | xargs grep "conf"
- 4.Django模板语言和分页
继承 extends 子版只能继承一个父模板 1.父模板 master.html <!DOCTYPE html> <html lang="en"> < ...