I am using tag field as a flag for text fields text view fields for auto-jumping to the next field:
- (BOOL)findNextEntryFieldAsResponder:(UIControl *)field {
BOOL retVal = NO;
for (UIView* aView in mEntryFields) {
if (aView.tag == (field.tag + 1)) {
[aView becomeFirstResponder];
retVal = YES;
break;
}
}
return retVal;
}
It works fine in terms of auto-jumping to the next field when Next key is pressed. However, my case is that the keyboards are different some fields. For example, one fields is numeric & punctuation, and the next one is default (alphabetic keys). For the numeric & punctuation keyboard is OK, but the next field will stay as the same layout. It requires user to press 123 to go back ABC keyboard.
I am not sure if there is any way to reset the keyboard for a field as its keyboard defined in xib? Not sure if there is any APIs available? I guess I have to do something is the following delegate?
-(void)textFieldDidBegingEditing:(UITextField*) textField {
// reset to the keyboard to request specific keyboard view?
....
}
OK. I found a solution close to my case by slatvik:
-(void) textFieldDidBeginEditing:(UITextField*) textField {
textField.keyboardType = UIKeybardTypeAlphabet;
}
However, in the case of the previous text fields is numeric, the keyboard stays numeric when auto-jumped to the next field. Is there any way to set keyboard to alphabet mode?
Finally I find out a way to solve my issue. In my case, I like to use Entry or Next key to auto-jump to the next available field. If the two fields in sequence have totally different keyboards, the keyboard change should be fine. However, if the one is keyboard with numeric mode, and the next one is in alphabet mode, then the auto-jump would not cause the same keyboard to change mode.
The main reason is that my call to findNextEntryFieldAsResponder: method is done in textFieldShouldReturn: delegate method. The call caused the next field becomes the responder:
I found this in my NSLog debug message:
What I need to do is to the next field as responder out of textFieldShouldReturn: event call. I tried to use iphone’s local Notification framework to fire a async-notification event within the textFieldShouldReturn: and it does what I expect.
Here is my updated codes:
where specialInputs is a NSArray of int values. It is a property can be set with a list tags as special inputs. Actually, I think all the inputs can be treated as specialInputs and it does work as well(just more notifications).
I have a complete description of codes in my blog.