how to insert text at any cursor position in uitextview?

前端 未结 4 961
走了就别回头了
走了就别回头了 2021-02-13 01:42

i want to implement Code by which i can start to insert text at any position of cursor in UITextView in iphone sdk

any idea? thank you in advance..

i refereed th

4条回答
  •  不知归路
    2021-02-13 02:12

    Dan's answer is manually changing the text. It's not playing well with UITextView's UndoManager.

    Actually it's very easy to insert text with UITextInput protocol API, which is supported by UITextView and UITextField.

    [textView replaceRange:textView.selectedTextRange withText:insertingString];
    

    Note: It's selectedTextRange in UITextInput protocol, rather than selectedRange

提交回复
热议问题