Nov
26
2011

CLKeypad, A Customized iPhone Keyboard NumberPad

CLKeypad is a customized iPhone keyboard NumberPad with a customized toolbar. It has the same function as UIKeyboardTypeNumberPad except that CLKeypad provide an extra decimal point button. You can customize the toolbar and each of the keys with your own image.

CLKeypad

To use CLKeypad, you just need to implement it’s delegates,

- (void)hideCLKeypad;
- (void)numberPressed:(NSString *)number;

and the UITextFieldDelegate to assign the texfield’s inputView(toolbar) and inputAccessoryView(keypad):

-(void)textFieldDidBeginEditing:(UITextField *)textField{
    if (keypad == nil) {
        keypad = [[CLKeypad alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, KEYBOARD_HEIGHT)];
        keypad.delegate = self;
    }
    if (textField.inputAccessoryView == nil) 
        [textField setInputAccessoryView:keypad.toolbar];
    if (textField.inputView == nil) 
        textField.inputView = keypad;
}

The first delegate, ‘hideCLKeypad’ method is for dismissing the keypad when user hit the ‘done’ button on the toolbar. The second delegate, ‘numberPressed’ method will pass the number pressed to your controller.

A sample code is included in my github, you are free to download, edit and use it for your own project.

For tutorial on how to implement this custom keypad, stay tuned for my next post.

About the Author:

Cayden is a programmer that expertize in ios and PHP development.

Leave a comment

Ads

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Facebook Page

Categories