1
我试图隐藏UITextView的文本,用作密码输入,使用点而不是实际文本。该文本视图称为TV_Password。 当它为空时,文本不应该被隐藏,应该用字符串“Password”替换secureTextEntry不隐藏我的UITextView文本
我在网络上发现解决方案是将以下属性更改为true。
self.TV_Password.secureTextEntry = true
不幸的是,这仍然不能隐藏我的文字。 我将修改移动到textViewShouldBeginEditing而不是textViewDidBeginEditing,建议有人遇到这种问题,但它仍然不起作用。 我有各种断点告诉我的指示是真的完成,但没有任何反应..
任何想法。?
//MARK: TextViews editing
func textViewShouldBeginEditing(textView: UITextView) -> Bool {
if (textView == self.TV_Password){
if (self.TV_Password.text == "Password"){
//empty text
self.TV_Password.text = ""
//enable secured text
self.TV_Password.secureTextEntry = true
}
}
return true
}
func textViewDidEndEditing(textView: UITextView) {
if (textView == self.TV_Password) {
//if password empty
if (self.TV_Password.text == ""){
//disable secured text
self.TV_Password.secureTextEntry = false
//fill with the word "Password"
self.TV_Password.text = "Password"
}
}
}
'UITextView'没有安全的输入模式。 – dasdom
如果您需要该功能,您将需要使用“UITextField”。 – Cole
奇怪的是,Xcode知道这样的方法和自动完成..即使对于UITextView .. 无论如何,非常感谢! – BUZZE