I would like to create a dialogue with a pin code, for example one that you can enable on iPhone.
For those who have not seen this, it consists of four drawers and a numeric keypad. When you enter a number, a dot appears in the first field. Etc. When you click the Delete button, the last point will be deleted.
I have this set as four UITextFields, and in my delegate I listen:
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
[self performSelector:@selector(pickNext:) withObject:textField afterDelay:0.0];
return YES;
}
PickNext: method will switch to the next UITextField, for example:
- (void)pickNext:(UITextField*)textField
{
switch ([textField tag]) {
case 1:
[pin2 becomeFirstResponder];
break;
case 2:
[pin3 becomeFirstResponder];
break;
case 3:
[pin4 becomeFirstResponder];
break;
case 4:
[textField resignFirstResponder];
break;
default:
break;
}
}
It really works, but the problem for me is that the delete key does not cause any notifications when the UITextField is already empty. Therefore, I can not go to the previous UITextField.
And someone has a better solution how to solve this problem. I think a hidden text box ... ??