0

iPhoneキーボードの「、」ボタンを無効にする方法、または少なくともユーザーがUITextFieldに「、」を入力できないようにする方法はありますか?

4

2 に答える 2

3

はい。テキスト フィールドのデリゲートを設定してから、次のメソッドを実装します。

- (BOOL)textField:(UITextField *)tf shouldChangeCharactersInRange:(NSRange)r replacementString:(NSString *)str
{
    if (tf == theTextFieldYouWannaBehaveLikeThis) {
        if ([str isEqualToString:@","]) {
            return NO;
        }
    }
    return YES;
}
于 2012-09-01T18:14:05.433 に答える
0

keyboardTypeのプロパティがありますUITextField:

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;
于 2012-09-01T18:16:28.633 に答える