I tried to do this the same way as I'm doing it with a UITextField
:
textView.selectedTextRange = textView.textRange(from: textView.beginningOfDocument, to: textView.endOfDocument)
What am I doing wrong?
You should make the text field the first responder before selecting it:
textView.becomeFirstResponder()
textView.selectedTextRange = textView.textRange(from: textView.beginningOfDocument, to: textView.endOfDocument)
...or, better yet, just call selectAll
:
textView.selectAll(self)