0

I'm currently developing an application with a primarily Japanese (secondary English) market, and I've found that I cannot set UIKeyboardType for a textfield and get it to actually work if using a tenkey/flick style Japanese keyboard. Even though the UIKeyboardType should be responding appropriately,

userIdField = [[[UITextField alloc] initWithFrame:CGRectMake(120, 5, 185, 35)]autorelease];
userIdField.delegate = self;
userIdField.keyboardType = UIKeyboardTypeASCIICapable;
userIdField.autocorrectionType = UITextAutocorrectionTypeNo;
userIdField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
userIdField.returnKeyType = UIReturnKeyDone;
userIdField.autocapitalizationType = UITextAutocapitalizationTypeNone;
userIdField.backgroundColor = [UIColor clearColor];
[cell addSubview:userIdField];

when I tap the textfield it will open up the default Japanese tenkey style keyboard. I have tried UIKeyboardTypeASCIICapable, UIKeyboardTypeURL, UIKeyboardTypeEmailAddress, UIKeyboardTypeNamePhonePad and they always show the default tenkey Japanese keyboard. I know that the code is being read, as setting UIKeyboardTypePhonePad works without flaw, but for some reason the phone will not display anything but the default Japanese tenkey keyboard.

Is there any way to fix this, or is this a bug that has existed since the dawn of time? How do I force the user to use a keyboard which can ONLY input alphabet,number,"_/. characters?

Using a Hangul (Korean) keyboard, it works sporadically- ASCII keyboard comes up fine, url keyboard comes up Hangul with a .com button. For ASCIICapable, looking at the UITextInputTraits.h file, it says: UIKeyboardTypeASCIICapable, // Displays a keyboard which can enter ASCII characters, non-ASCII keyboards remain active Which doesn't make any sense as both Hangul and Japanese are non-ASCII, but Hangul + ASCIICapable = ASCII (though it should be Hangul as it is non-ascii), whereas Japanese tenkey + ASCIICapable = Japanese tenkey.

I saw other posts about changing keyboard language programmatically, which cannot be done, but this question is a more focused on asking why the kind of keyboard specified by UIKeyboardType doesn't show up.

Nookaraju
  • 1,648
  • 13
  • 24
n_b
  • 1,056
  • 1
  • 9
  • 19

1 Answers1

0

The reason why the Japanese tenkey keyboard is displayed is because it is technically an ASCIICapable keyboard, even though you must first click on the ABC button to make the keyboard change to ASCII input. I have thought of a way to fix this problem, though it is convoluted and full of problems:

  1. 2 textfields, one of top of the other. Top textfield hidden
  2. Bottom textfield has secureTextEntry set to YES, which forces an actual ASCII keyboard, but obfuscates entered text
  3. When the user taps the bottom textfield, the top textfield becomes shown
  4. When text is entered on the keyboard, it first goes to the bottom textField, which then sets the text of the top textField. Otherwise, you'd just get the full black circles used to hide text entry.

If you make a mistake and want to edit text, then you'd have to do a bunch of other code to get it to work right, assigning first responders and the like (like making sure that when text gets entered, it is entered into the bottom textfield at the right place).

This is obviously not an optimal solution.

n_b
  • 1,056
  • 1
  • 9
  • 19