iOS 7: Best way to implement an textview that presents previous input but is easy to clear

Posted by Frank R. on Stack Overflow See other posts from Stack Overflow or by Frank R.
Published on 2014-06-11T13:07:00Z Indexed on 2014/06/11 15:25 UTC
Read the original article Hit count: 188

Filed under:
|

I'm porting a Mac app to the iPhone and I've run into an unexpected problem.

On the Mac there's a text field that is automatically pre-selected (= first responder) when a dialog shows up. The text field shows the text you entered in the field the last time and the text is pre-selected so that if you just start typing it gets cleared away. If you want to edit the existing text instead you just hit the forwards or backwards arrow.

On the iPhone this behavior seems very hard to implement. The text view shows up with the old text and I can even get it to pre-select but whatever I do the result is not quite right.

When I use

[aTextView setMarkedText: myText
           selectedRange: newRange];

the text does show up as marked and if I just start typing the old text goes away. However there's no equivalent to the cursor keys on iOS, so I cannot NOT erase the text.. which is hardly the point.

What kind of iOS idiom would be appropriate for giving the option to either edit or overwrite existing text?

Best regards,

Frank

© Stack Overflow or respective owner

Related posts about ios

Related posts about uitextview