secureTextEntry不会隐藏我的UITextView的文本
我试图隐藏UITextView的文本,用作密码input,使用点而不是实际的文本。 这个文本视图被称为TV_Password。 当它为空时,文本不应该被隐藏,应该用string“Password”replace
我在网上发现解决方法是将以下属性更改为true。
self.TV_Password.secureTextEntry = true
不幸的是,这仍然不能隐藏我的文字。 我将这些修改移到了textViewShouldBeginEditing,而不是textViewDidBeginEditing,build议给有此类问题的人,但是仍然不起作用。 我有各种断点告诉我的指示是真的完成,但没有任何反应。
任何想法 。?
//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没有安全的入口模式,而是使用UITextField。 非常感谢!