Is there a way to detect if a UITextField exists using the Tag property? Essentially i have a number of textfields created dynamically and I want to tab through the fields using the return key on the keypad.
I am trying to use the below code form another post but ‘textField.superview’ returns null. I am creating the textfields programatically.
-(BOOL)textFieldShouldReturn:(UITextField*)textField;
{
NSInteger nextTag = textField.tag + 1;
// Try to find next responder
UIResponder* nextResponder = [textField.superview viewWithTag:nextTag];
if (nextResponder) {
// Found next responder, so set it.
[nextResponder becomeFirstResponder];
} else {
// Not found, so remove keyboard.
[textField resignFirstResponder];
}
return NO; // We do not want UITextField to insert line-breaks.
}
You can directly check like this
For setting the tag