Reputation: 215
I'm using an alert view and the options are to change one of the values that are wrong so what I want to do is when the user selects which value he wants to change the text field corresponding to the value start editing.
Upvotes: 9
Views: 5324
Reputation: 1075
Swift 4.2
Write this line of code in viewDidLoad
textField.becomeFirstResponder()
Upvotes: 3
Reputation: 8012
The correct way is the instruct the UITextField to receive focus via becomeFirstResponder
:
if (buttonIndex == 0) {
[self.givenVin becomeFirstResponder];
NSLog(@"edit ");
} else if (buttonIndex == 1) {
[self.givenVout becomeFirstResponder];
}
Upvotes: 3
Reputation: 793
If you have named a UITextField givenVin, then you could try with:
[self.givenVin becomeFirstResponder];
Upvotes: 13