【问题标题】:secureTextEntry doesn't hide the text of my UITextViewsecureTextEntry 不会隐藏我的 UITextView 的文本
【发布时间】:2016-02-13 17:10:53
【问题描述】:

我试图隐藏用作密码输入的 UITextView 的文本,使用点而不是实际文本。此文本视图称为 TV_Password。 当其为空时,文本不应隐藏,应替换为字符串“密码”

我在网上找到解决方法是将以下属性更改为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 没有安全进入模式。
  • 如果你想要那个功能,你会想要使用UITextField
  • 奇怪的是 Xcode 知道这样的方法并自动完成..即使是 UITextView.. 无论如何,非常感谢!

标签: ios swift uitextview


【解决方案1】:

回答: UITextView 没有安全输入模式,请改用 UITextField。 非常感谢!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-11
    • 1970-01-01
    • 2013-06-25
    • 2012-08-05
    • 2022-01-10
    相关资源
    最近更新 更多