带有安全条目的UITextField,在编辑之前总是被清除 [英] UITextField with secure entry, always getting cleared before editing

查看:122
本文介绍了带有安全条目的UITextField,在编辑之前总是被清除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个奇怪的问题,当我尝试编辑它时,我的UITextField持有一个安全条目总是被清除。我在字段中添加了3个字符,转到另一个字段并返回,光标位于第4个字符位置,但是当我尝试添加另一个字符时,字段中的整个文本被新字符清除。我在笔尖中未选中编辑开始时清除。那么问题是什么呢?如果我删除安全入口属性,一切正常,那么,这是安全输入文本字段的属性吗?有没有办法阻止这种行为?

I am having a weird issue in which my UITextField which holds a secure entry is always getting cleared when I try to edit it. I added 3 characters to the field, goes to another field and comes back, the cursor is in 4th character position, but when I try to add another character, the whole text in the field gets cleared by the new character. I have 'Clears when editing begins' unchecked in the nib. So what would be the issue? If I remove the secure entry property, everything is working fine, so, is this the property of Secure entry text fields? Is there any way to prevent this behaviour?

推荐答案

设置,

textField.clearsOnBeginEditing = NO;

注意:如果 secureTextEntry = YES ,这将不起作用。默认情况下,iOS会在编辑之前清除安全输入文本字段的文本,无论 clearsOnBeginEditing 是YES还是NO。

Note: This won't work if secureTextEntry = YES. It seems, by default, iOS clears the text of secure entry text fields before editing, no matter clearsOnBeginEditing is YES or NO.

这篇关于带有安全条目的UITextField,在编辑之前总是被清除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆