Li.*_*Rui 2 uitextview ios emoji swift
这里,str包含表情符号并且设置的光标位置不正确:
let cursorPosition = str.characters.count
let cursorRange = NSRange(location: cursorPosition, length: 0)
textInputView.selectedRange = cursorRange
textInputView.scrollRangeToVisible(cursorRange)
Run Code Online (Sandbox Code Playgroud)

看起来您想将光标放在 的最后textView。像这样尝试一下。
textInputView.becomeFirstResponder()
let cursorPosition = str.utf16.count
let cursorRange = NSRange(location: cursorPosition, length: 0)
textInputView.selectedRange = cursorRange
textInputView.scrollRangeToVisible(cursorRange)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1255 次 |
| 最近记录: |