开发者

How to hide number button on UIKeyboard?

Is there a way to hide number button and space button?

How to hide number button on UIKeyboard?

Mantaining UIKeyboard transparency??

I need a keyboard with only letters, backspace and NEXT button, not开发者_高级运维hing else.

I need compatibility from iOS 3.1+!

thanks.


This page has a great tutorial about customizing a keyboard. Looks like you might be able to use this to hide the buttons you don't want, or change the current buttons.

Basically, you should register as an observer for the UIKeyboardWillShowNotification:

[[NSNotificationCenter defaultCenter] addObserver:self 
                                         selector:@selector(keyboardWillShow:) 
                                             name:UIKeyboardWillShowNotification 
                                           object:nil];

and do customization inside your keyboardWillShow: notification handler:

- (void)keyboardWillShow:(NSNotification *)notification { 
    // locate keyboard view
    UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
    UIView* keyboard;
    for(int i=0; i<[tempWindow.subviews count]; i++) {
        keyboard = [tempWindow.subviews objectAtIndex:i];
        // keyboard view found; add the customization to it
        if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES)
            UIView *customView = [[UIView alloc] init];
            // do stuff to customView here
            [keyboard addSubview:customView];
    }
}

The prefix @"<UIKeyboard" in this line if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES) might be different. So you should loop through once using NSLog to print out all the subview descriptions to see what string you need to check for.


And here is some info about the default keyboards that are provided (non-customized)

UIKeyboardType - The type of keyboard to display for a given text-based view.

Check out this UIKeyboardType page for images of each keyboard type.

Here are some definitions from UITextInputTraits Protocol Reference

typedef enum {
   UIKeyboardTypeDefault,
   UIKeyboardTypeASCIICapable,
   UIKeyboardTypeNumbersAndPunctuation,
   UIKeyboardTypeURL,
   UIKeyboardTypeNumberPad,
   UIKeyboardTypePhonePad,
   UIKeyboardTypeNamePhonePad,
   UIKeyboardTypeEmailAddress,
   UIKeyboardTypeDecimalPad,
   UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable
} UIKeyboardType;
  • UIKeyboardTypeDefault

Use the default keyboard for the current input method. Available in iOS 2.0 and later.

  • UIKeyboardTypeASCIICapable

Use a keyboard that displays standard ASCII characters. Available in iOS 2.0 and later.

  • UIKeyboardTypeNumbersAndPunctuation

Use the numbers and punctuation keyboard. Available in iOS 2.0 and later.

  • UIKeyboardTypeURL

Use a keyboard optimized for URL entry. This type features “.”, “/”, and “.com” prominently. Available in iOS 2.0 and later.

  • UIKeyboardTypeNumberPad

Use a numeric keypad designed for PIN entry. This type features the numbers 0 through 9 prominently. This keyboard type does not support auto-capitalization. Available in iOS 2.0 and later.

  • UIKeyboardTypePhonePad

Use a keypad designed for entering telephone numbers. This type features the numbers 0 through 9 and the “*” and “#” characters prominently. This keyboard type does not support auto-capitalization. Available in iOS 2.0 and later.

  • UIKeyboardTypeNamePhonePad

Use a keypad designed for entering a person’s name or phone number. This keyboard type does not support auto-capitalization. Available in iOS 2.0 and later.

  • UIKeyboardTypeEmailAddress

Use a keyboard optimized for specifying email addresses. This type features the “@”, “.” and space characters prominently. Available in iOS 2.0 and later.

  • UIKeyboardTypeDecimalPad

Use a keyboard with numbers and a decimal point. Available in iOS 4.1 and later.

  • UIKeyboardTypeAlphabet

Deprecated. Use UIKeyboardTypeASCIICapable instead. Available in iOS 2.0 and later.


Apart from making your own keyboard (it's not that difficult) use UITextField and the delegate method to filter the input.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜