如何向下移动textView光标?
How to move downward the textView cursor?
谁能告诉我如何向下移动 textView 光标,因为我不知道该怎么做,
还有我应该把它放在哪里
在 textViewDidBeginEditing(_ textView: UITextView) 或在 textViewDidEndEditing(_ textView: UITextView)
提前致谢
这会将光标移动到文本末尾:
func textViewShouldBeginEditing(_ textView: UITextView) -> Bool {
DispatchQueue.main.async {
textView.selectedRange = NSRange(location: textView.text.count, length: 0)
}
return true
}
如果要从新行开始文本,请在 return 之前添加此内容 true:
textView.text = textView.text + "\n"
如果要跳过两行,将其设为“\n\n”,依此类推。
谁能告诉我如何向下移动 textView 光标,因为我不知道该怎么做, 还有我应该把它放在哪里 在 textViewDidBeginEditing(_ textView: UITextView) 或在 textViewDidEndEditing(_ textView: UITextView) 提前致谢
这会将光标移动到文本末尾:
func textViewShouldBeginEditing(_ textView: UITextView) -> Bool {
DispatchQueue.main.async {
textView.selectedRange = NSRange(location: textView.text.count, length: 0)
}
return true
}
如果要从新行开始文本,请在 return 之前添加此内容 true:
textView.text = textView.text + "\n"
如果要跳过两行,将其设为“\n\n”,依此类推。