【发布时间】:2020-04-26 18:36:59
【问题描述】:
我正在使用 Mac Catalyst 将我的 iPad 应用程序调整为 Mac,并且在 UITableViewCell 中出现 UITextView 的异常行为。当我呈现视图时,我会自动将 textview 置于焦点位置,但在 Mac 上,无论我在其中输入什么内容,文本都会显示为大写。这在 iPhone 或 iPad 版本上从未发生过。我不确定为什么会发生这种情况(我的大写锁定未打开),我尝试了多个键盘并得到相同的结果。也不是每次都发生,非常随机。
这是我的代码:
class TextViewCell: UITableViewCell {
override func awakeFromNib() {
super.awakeFromNib()
textView.delegate = self
textView.isScrollEnabled = false
textView.returnKeyType = .done
}
//populate funcion called by the tableview. Just sets the textView into focus if it's the first time the view shows
func populate(isFirstLoad: Bool = false) {
//I set isFirstLoad to false after calling on this function in the tableview so this is only called on once
if isFirstLoad {
self.titleTF.becomeFirstResponder()
}
}
}
// MARK: - textView functions
extension TextViewCell: UITextViewDelegate {
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
if (text == "\n") {
textView.resignFirstResponder()
return false
}
return true
}
}
有其他人遇到过这个问题并知道如何解决吗???
【问题讨论】:
标签: swift xcode uitextview mac-catalyst