Upon a View Controller loading from code where a UITextView is prepopulated with some text, I would like the cursor to be at the beginning of the text not at the end.
The following code however is having no effect. The cursor still appears at the end of the prepopulated text.
What can I do to get the cursor over to the beginning of the text?
self.myTextView.text = @"Text that should go after cursor";
[self.myTextView becomeFirstResponder];
UITextPosition* start = self.myTextView.beginningOfDocument;
UITextRange *newRange = [self.myTextView textRangeFromPosition:start toPosition:start];
NSLog("newRange is%@",newRange);
[self.myTextView setSelectedTextRange:newRange];
Note, newRange logs as <_UITextKitTextRange: 0x17463f0c0> (0, 0)F so I think the next line is not actually changing the rang. But I don't know of another way to do this.