【objective-c】 setKeyboardType一覧


setKeyboardTypeで指定する定数がいっぱいあったので一覧化。
違いがわかったりわからなかったり。

iOSでテキスト入力箇所をアクティブにした際に呼ばれるキーボードの指定一覧

指定

サンプル
UIKeyboardAppearanceDefault

UIKeyboardTypeDefault1
UIKeyboardTypeDefault2

UIKeyboardTypeTwitter

UIKeyboardTypeTwitter1UIKeyboardTypeTwitter2

UIKeyboardTypeAlphabet

UIKeyboardTypeAlphabet

UIKeyboardTypeEmailAddress

UIKeyboardTypeEmailAddress1
UIKeyboardTypeEmailAddress2

UIKeyboardTypePhonePad

UIKeyboardTypePhonePad

UIKeyboardTypeNumberPad

UIKeyboardTypeNumberPad

UIKeyboardTypeURL

UIKeyboardTypeURL1UIKeyboardTypeURL2

UIKeyboardTypeNumbersAndPunctuation

UIKeyboardTypeNumbersAndPunctuation1UIKeyboardTypeNumbersAndPunctuation2

UIKeyboardTypeASCIICapable

UIKeyboardTypeASCIICapable

UIKeyboardTypeDefault

UIKeyboardTypeDefault1UIKeyboardTypeDefault2

おまけ

テキストエリア生成コードサンプル

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;
}

iOSプログラミング逆引きリファレンス108 ~知りたいことがすぐわかるiPhoneプログラミングテクニック~

iPhoneプログラミングUIKit詳解リファレンス

iOSデバッグ&最適化技法 for iPad/iPhone
詳解 Objective-C 2.0 第3版

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です