How to set the position of the cursor in UITextView

后端 未结 6 562
南旧
南旧 2020-12-07 21:12

I have an UITextView in my iPhone app which is editable.

New button is created inside the UITextView whenever user select a specific function.

As the butto

6条回答
  •  忘掉有多难
    2020-12-07 22:12

    change selectedRange of your textView. for example to place cursor at position 3:

    [textView setSelectedRange:NSMakeRange(3, 0)];

    In your case, added some spaces on the textView contents might helps. and observer textview 's textDidChanged event to prevent these space will be deleted by user.

提交回复
热议问题