2017-04-06 12 views
0

str이 그림 이모티콘을 포함 올바르지 않은 설정하고 cursorPosition는 올바르지 않습니다 :UITextView.text : cursorPosition 여기

let cursorPosition = str.characters.count 
    let cursorRange = NSRange(location: cursorPosition, length: 0) 
    textInputView.selectedRange = cursorRange 
    textInputView.scrollRangeToVisible(cursorRange) 

+0

커서가 올바르지 않습니다. 나에게 잘 어울린다. – kennytm

+0

@kennytm 커서는 ":"뒤에 있어야하지만 지금은 앞에 있습니다 ... –

답변

2

마지막에 커서를 원하는 것처럼 보이게됩니다 textView 이런 식으로 시도해보십시오.

textInputView.becomeFirstResponder() 
let cursorPosition = str.utf16.count 
let cursorRange = NSRange(location: cursorPosition, length: 0) 
textInputView.selectedRange = cursorRange 
textInputView.scrollRangeToVisible(cursorRange) 
+0

맞아요, 고마워요. –