UIKeyboardTypeDecimalPad with Japanese keyboard doesn't display decimal point
I'm writing an iPhone app that lets users input numbers. The numbers are sometimes decimals (e.g., 5.367). I've been using UIKeyboardTypeDecimalPad as the keyboard, which mostly works great.
Where I ran into problems is when I tested changing the Language, Region Format, and Calendar to Japanese. When I did that, it added a new keyboard (so now the phone has two in Settings, General, Keyboard), named "Japanese - Ten Key".
In this state, the UIKeyboardTypeDecimalPad no longer displays the decimal point key! I can sort of understand that if one assumes that UIKeyboardTypeDecimalPad will only be used for currency input (one does not typically enter fractions of Yen), but that's not why I'm using it.
Here's the code if that helps:
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 130, 31)];
textField.tag = 7;
textField.delegate = self;
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.text = NSLocalizedString(@"Some_Key", nil);
textField.keyboardType = UIKeyboardTypeD开发者_C百科ecimalPad;
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
Am I stuck writing a custom keyboard? Or is there some way to inform the UIKeyboardTypeDecimalPad that I'm not using it for currency?
Use this line: It'll resolve your problem.
NSString *firstString = @"102.08", *finalString;
finalString = [[firstString stringByReplacingOccurancesOfString:@"." withString:@","];
精彩评论