Insert space in current cursor location

155 Views Asked by At

I've searched stackoverflow and the web, but couldn't find something that works. I have a UIButton that inserts a space when you click on it, now it adds the space at the end of the UITextField even when the cursor is in the middle.

How can I add space at current cursor position with UIButton click?

Thanks in advance.

1

There are 1 best solutions below

0
On BEST ANSWER

For iOS 5+, try

[textField replaceRange:[textField selectedTextRange] withText:@" "];