ios - PopoverPresentationController 内的 UITextView 不响应其委托(delegate)方法

标签 ios swift uitextview uipopovercontroller uitextviewdelegate

enter image description here

我在使 UILabel 通过更改其文本颜色来对 UITextView 使用react时遇到问题。

所以当我的 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
            }
     }

最佳答案

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

这是一张图片。

enter image description here

关于ios - PopoverPresentationController 内的 UITextView 不响应其委托(delegate)方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41712938/

相关文章:

javascript - MobileSafari 的正确触摸按钮行为

ios - 枚举 : Count and list all cases (from outside! )

ios - 根据屏幕尺寸平移/缩放 UIImageView

ios - 符合关联类型协议(protocol)的对象的 Swift 集合

objective-c - 在 UITextView 中移动光标

swift - 出现键盘时如何将 TextView 高度设置为左侧空间(Swift)

ios - 重复的 UITextView 不显示原始文本中的所有文本

javascript - 为什么 showModal 在 iOS 中显示全屏?

ios - 单击 SpriteKit 叠加标签时如何在 SceneKit 中切换场景?

ios - 为 objective-c 中的方法传递未知类型的参数,可能吗?