I had the same problem and solved it like this:
First, implement the UITextFieldDelegate in your ViewController
class ViewController : UITextFieldDelegate
Then set the textField delegate to "self"
textField.delegate = self
Then add this function to the ViewController class
func textFieldDidBeginEditing(textField: UITextField) { textField.selectedTextRange = textField.textRangeFromPosition(textField.beginningOfDocument, toPosition: textField.endOfDocument) }
If you are already using ViewController as a delegate for other text fields that you do not want to behave in this way, you can simply use a switch, for example:
func textFieldDidBeginEditing(textField: UITextField) { switch textField { case yourTextField: textField.selectedTextRange = textField.textRangeFromPosition(textField.beginningOfDocument, toPosition: textField.endOfDocument) break; case default: break; } }
source share