I have a UITextView and a UITextField. I would like to select a range of text in the text view and then edit the text in the text field, which will perform some action on the selected text from the text view. Is there a way to edit the text field without losing the selected text in the text view?
Maintain text selection with multiple input fields
You should store the selection range of UITextView.
I would override resignFirstResponder by subclassing UITextView
func resignFirstResponder() -> Bool Discussion
The default implementation returns true, resigning first responder status. You can override this method in your custom responders to update your object's state or perform other actions, such as removing the highlight from a selection. You can also return false, refusing to relinquish first responder status. If you override this method, you must call super(the superclass implementation) at some point in your code.
Note: read this as well: