2009-07-13 6 views
5

アルファベットキーボードのみを使用したいのですが、どのように制限するのですか?私は、次のステートメントを使用しましたが、それは、私はあなただけの入力アルファベット文字にキーボードを制限することはできませんaffraidだ数字の1UIkeyboardタイプ

tempTextField.keyboardType = UIKeyboardTypeAlphabet;  

答えて

9

をキーボードに変換ボタンを非表示にしていません。利用可能keyboardTypesがUITextInputTraitsプロトコルのリファレンスに記載されている、ヘッダファイルの中でも、より詳細にされています

typedef enum { 
    UIKeyboardTypeDefault,    // Default type for the current input method. 
    UIKeyboardTypeASCIICapable,   // Displays a keyboard which can enter ASCII characters, non-ASCII keyboards remain active 
    UIKeyboardTypeNumbersAndPunctuation, // Numbers and assorted punctuation. 
    UIKeyboardTypeURL,     // A type optimized for URL entry (shows ./.com prominently). 
    UIKeyboardTypeNumberPad,    // A number pad (0-9). Suitable for PIN entry. 
    UIKeyboardTypePhonePad,    // A phone pad (1-9, *, 0, #, with letters under the numbers). 
    UIKeyboardTypeNamePhonePad,   // A type optimized for entering a person's name or phone number. 
    UIKeyboardTypeEmailAddress,   // A type optimized for multiple email address entry (shows space @ . prominently). 

    UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable, // Deprecated 

} UIKeyboardType; 

は、私はあなたがSDKから欠落して欲しいものを感じます。私はあなたが言及したような新しいキーボードタイプをAppleに要求するバグレポートを提出します。

バグレポートを提出し、新しいキーボードタイプがSDKで利用可能になるのを待っている以外に、あなたの解決策は何ですか?テキストフィールドの入力を確認しています。これは、UITextFieldのdelegateプロパティを割り当てて、UITextFieldDelegateメソッドのtextField:shouldChangeCharactersInRange:replacementString:を実装し、置換文字列に数値が含まれていない場合にのみYESを返します。

HTH

+1

@drvdijkがここで提案するものの実装があります:http://stackoverflow.com/questions/1013647/filtering-characters-entered-into- a-uitextfield/1015262#1015262 – teabot

4

更新キーボードタイプ

typedef NS_ENUM(NSInteger, UIKeyboardType) { 
     UIKeyboardTypeDefault,    // Default type for the current input method. 
     UIKeyboardTypeASCIICapable,   // Displays a keyboard which can enter ASCII characters, non-ASCII keyboards remain active 
     UIKeyboardTypeNumbersAndPunctuation, // Numbers and assorted punctuation. 
     UIKeyboardTypeURL,     // A type optimized for URL entry (shows ./.com prominently). 
     UIKeyboardTypeNumberPad,    // A number pad (0-9). Suitable for PIN entry. 
     UIKeyboardTypePhonePad,    // A phone pad (1-9, *, 0, #, with letters under the numbers). 
     UIKeyboardTypeNamePhonePad,   // A type optimized for entering a person's name or phone number. 
     UIKeyboardTypeEmailAddress,   // A type optimized for multiple email address entry (shows space @ . prominently). 
    #if __IPHONE_4_1 <= __IPHONE_OS_VERSION_MAX_ALLOWED 
     UIKeyboardTypeDecimalPad,    // A number pad with a decimal point. 
    #endif 
    #if __IPHONE_5_0 <= __IPHONE_OS_VERSION_MAX_ALLOWED 
     UIKeyboardTypeTwitter,    // A type optimized for twitter text entry (easy access to @ #) 
    #endif 

     UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable, // Deprecated 

    }; 
関連する問題