setKeyboardTypeで指定する定数がいっぱいあったので一覧化。
違いがわかったりわからなかったり。
iOSでテキスト入力箇所をアクティブにした際に呼ばれるキーボードの指定一覧
指定 | サンプル |
---|---|
UIKeyboardAppearanceDefault | ![]() ![]() |
UIKeyboardTypeTwitter | ![]() ![]() |
UIKeyboardTypeAlphabet | ![]() |
UIKeyboardTypeEmailAddress | ![]() ![]() |
UIKeyboardTypePhonePad | ![]() |
UIKeyboardTypeNumberPad | ![]() |
UIKeyboardTypeURL | ![]() ![]() |
UIKeyboardTypeNumbersAndPunctuation | ![]() ![]() |
UIKeyboardTypeASCIICapable | ![]() |
UIKeyboardTypeDefault | ![]() ![]() |
おまけ
テキストエリア生成コードサンプル
objective-c: -(UITextField*)makeTextField:(CGRect)rect text:(NSString*)text type:(NSInteger*)type{ //テキストフィールドを生成し、rect,text,色,キーボードに関する情報をセットして返す。 UITextField* textField = [[[UITextField alloc] init] autorelease]; [textField setFrame:rect]; [textField setBackgroundColor:[UIColor whiteColor]]; [textField setBorderStyle:UITextBorderStyleRoundedRect]; //以下がキーボード関連。キーボードのアピアランス、キーボードの種別、改行キーの種別 [textField setKeyboardAppearance:UIKeyboardAppearanceDefault]; switch((NSInteger)type){ case 1: [textField setKeyboardType:UIKeyboardTypeDefault]; [textField setText:@"UIKeyboardTypeDefault"]; break; case 2: [textField setKeyboardType:UIKeyboardTypeASCIICapable]; [textField setText:@"UIKeyboardTypeASCIICapable"]; break; case 3: [textField setKeyboardType:UIKeyboardTypeNumbersAndPunctuation]; [textField setText:@"UIKeyboardTypeNumbersAndPunctuation"]; break; case 4: [textField setKeyboardType:UIKeyboardTypeURL]; [textField setText:@"UIKeyboardTypeURL"]; break; case 5: [textField setKeyboardType:UIKeyboardTypeNumberPad]; [textField setText:@"UIKeyboardTypeNumberPad"]; break; case 6: [textField setKeyboardType:UIKeyboardTypePhonePad]; [textField setText:@"UIKeyboardTypePhonePad"]; break; case 7: [textField setKeyboardType:UIKeyboardTypeEmailAddress]; [textField setText:@"UIKeyboardTypeEmailAddress"]; break; case 8: [textField setKeyboardType:UIKeyboardTypeAlphabet]; [textField setText:@"UIKeyboardTypeAlphabet"]; break; case 9: [textField setKeyboardType:UIKeyboardTypeTwitter]; [textField setText:@"UIKeyboardTypeTwitter"]; break; default: break; } [textField setReturnKeyType:UIReturnKeyDone]; return textField; }