I am adding text fields to a view programmatically like this:
// Add a text field.
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(20, 100, 280, 40)];
textField.returnKeyType = UIReturnKeyNext;
[textField becomeFirstResponder];
[textField addTarget:self action:@selector(nextButtonPressed:) forControlEvents:UIControlEventEditingDidEndOnExit];
UITextField *textFieldTwo = [[UITextField alloc] initWithFrame:CGRectMake(20, 160, 280, 40)];
textFieldTwo.returnKeyType = UIReturnKeyDone;
[textFieldTwo addTarget:self action:@selector(doneButtonPressed:) forControlEvents:UIControlEventEditingDidEndOnExit];
How can I select these fields later on?
I know how to do this when I'm creating things using UI, but how does this work for dynamically added elements?
Example: I want to focus the second field when "Next" button is pressed.
Thanks!