这里,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)
