【问题标题】:UITextView inside of PopoverPresentationController doesn't response to its delegate methodPopoverPresentationController 内部的 UITextView 不响应其委托方法
【发布时间】:2017-01-18 06:42:42
【问题描述】:

我无法让我的 UILabel 通过更改其 textColor 来对我的 UITextView 做出反应。

所以当我的 UITextView 中有超过 250 个单词时,我的 UILabel 应该会变成红色。但是由于某种原因它没有这样做。

// class NewAppViewController: UIViewController, UITextViewDelegate...
    func textViewDidChange(_ textView: UITextView) {
            let characterCounts = commentTextField.text.characters.count
            wordCountLabel.text = String(250 - characterCounts)
            if (250 - characterCounts) < 0 {
                self.wordCountLabel.textColor = UIColor.red
                sendButton.isEnabled = false
            } else {
                sendButton.isEnabled = true
            }
     }

【问题讨论】:

  • 您是否为 uitextview 指定了委托?
  • 我想我找到了答案……
  • 您一定错过了添加代理。

标签: ios swift uitextview uipopovercontroller uitextviewdelegate


【解决方案1】:

我很粗心。我错误地使用了 UITextField。所以现在当我改回 UITextView 时,一切正常。

这是一张图片。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多