I have a UITextView containing a document. If the user touches the document, the insertion point (selectedRange property) is set appropriately and the UITextView becomes the first responder (keyboard appears). YAY!
How can I do the same thing programmatically? Let's say I have a button titled "Edit at character 1,000". I want that to set selectedRange to [1000, 0] and then make the textview become the first responder.
Problems...
textview.selectedRange setter only seems to have an effect when called from viewDidAppear.
[textview becomeFirstResponder] sets the insertion point to the end of the document.
So, the best I can do is first becomeFirstResponder and then set selectedRange. The user sees the view scroll to the bottom of the document and then back up to the desired insertion point. Kinda ugly.
Should I try to hide the ugliness by hacking 'scrollEnabled' and 'editable' flags during the transition? Or is there a better way to do this?