func textFieldDidBeginEditing(_ textField: UITextField) {
textField.selectAll(nil)
}
I have an issue where if I click at the left part of the Text Field (where the arrow point), the text doesn't get marked. Instead, the marker is positioned "before" the first character (see pic).
It works if I click on the text.
How can the text always get marked independently of where user clicks on the textfield?
It appears to be related to using .textAlignment = .right
Try it like this:
func textFieldDidBeginEditing(_ textField: UITextField) {
DispatchQueue.main.async {
textField.selectAll(nil)
}
}