I have a number field in which i want my customer to benefit number pad.
I am giving tags to text fields in order to handle next/done button in a textFieldShouldReturn method.
But when text field's keypad is set to number pad, its tag is reset.
How can i handle this situation?
[aliasField setFont:[UIFont fontWithName:@"Helvetica" size:14]];
aliasField.layer.cornerRadius = 4;
aliasField.layer.borderColor = [[UIColor colorWithRed:82.0f/255.0f green:191.0f/255.0f blue:240.0f/255.0f alpha:1.0]CGColor];
aliasField.layer.borderWidth = 1.0f;
[aliasField setTag:1];
[nameLastNameField setFont:[UIFont fontWithName:@"Helvetica" size:14]];
nameLastNameField.layer.cornerRadius = 4;
nameLastNameField.layer.borderColor = [[UIColor colorWithRed:82.0f/255.0f green:191.0f/255.0f blue:240.0f/255.0f alpha:1.0]CGColor];
nameLastNameField.layer.borderWidth = 1.0f;
[nameLastNameField setTag:2];
[cardNumberField setFont:[UIFont fontWithName:@"Helvetica" size:14]];
cardNumberField.layer.cornerRadius = 4;
cardNumberField.layer.borderColor = [[UIColor colorWithRed:82.0f/255.0f green:191.0f/255.0f blue:240.0f/255.0f alpha:1.0]CGColor];
cardNumberField.layer.borderWidth = 1.0f;
[cardNumberField setTag:3];
[cardNumberField setKeyboardType:UIKeyboardTypeNumberPad];
[validDateMonthField setFont:[UIFont fontWithName:@"Helvetica" size:14]];
validDateMonthField.layer.cornerRadius = 4;
validDateMonthField.layer.borderColor = [[UIColor colorWithRed:82.0f/255.0f green:191.0f/255.0f blue:240.0f/255.0f alpha:1.0]CGColor];
validDateMonthField.layer.borderWidth = 1.0f;
[validDateMonthField setTag:4];
[validDateMonthField setKeyboardType:UIKeyboardTypeNumberPad];
[validDateYearField setFont:[UIFont fontWithName:@"Helvetica" size:14]];
validDateYearField.layer.cornerRadius = 4;
validDateYearField.layer.borderColor = [[UIColor colorWithRed:82.0f/255.0f green:191.0f/255.0f blue:240.0f/255.0f alpha:1.0]CGColor];
validDateYearField.layer.borderWidth = 1.0f;
[validDateYearField setTag:5];
[validDateYearField setKeyboardType:UIKeyboardTypeNumberPad];
[cvvField setFont:[UIFont fontWithName:@"Helvetica" size:14]];
cvvField.layer.cornerRadius = 4;
cvvField.layer.borderColor = [[UIColor colorWithRed:82.0f/255.0f green:191.0f/255.0f blue:240.0f/255.0f alpha:1.0]CGColor];
cvvField.layer.borderWidth = 1.0f;
[cvvField setTag:6];
[cvvField setKeyboardType:UIKeyboardTypeNumberPad];
[bankNameField setFont:[UIFont fontWithName:@"Helvetica" size:14]];
bankNameField.layer.cornerRadius = 4;
bankNameField.layer.borderColor = [[UIColor colorWithRed:82.0f/255.0f green:191.0f/255.0f blue:240.0f/255.0f alpha:1.0]CGColor];
bankNameField.layer.borderWidth = 1.0f;
[bankNameField setTag:7];
//// text field should return method
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
// The user has pressed the "Return Key"
// Which I have set to "Next" for first two lines
// and "Done" for the last line, so jump to the next text field
NSLog(@"\"Return\" key pressed.");
// based on which text field we are in jump to the next
if (textField.tag == 7)
// We have reach the last line so hide keyboard
[textField resignFirstResponder];
// this is where you can perform Core Data updates if you like
else {
int nextTag = textField.tag + 1;
UIView *nextField = [self.view viewWithTag:nextTag];
[nextField becomeFirstResponder];
// Once the next text field is the first responder
// I need to make sure the user can see it
//[self makeActiveTextFieldVisible];
}
return YES;
}