Custom iPhone Keyboard

Here’s an idea: modify the existing keyboard to your own needs. First, register to be notified when it appears on screen:

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

Then, in your modifyKeyboard method:

- (void)modifyKeyboard:(NSNotification *)notification 
{
    UIView *firstResponder = [[[UIApplication sharedApplication] keyWindow] performSelector:@selector(firstResponder)];

    for (UIWindow *keyboardWindow in [[UIApplication sharedApplication] windows])
        for (UIView *keyboard in [keyboardWindow subviews])
            if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES)
            {
                MyFancyKeyboardView *customKeyboard = [[MyFancyKeyboardView alloc] initWithFrame: CGRectMake(0, 0, keyboard.frame.size.width, keyboard.frame.size.height);
                [keyboard addSubview: customKeyboard];
                [customKeyboard release];
            }
}

This adds your view on top of the original keyboard, so make sure you make it opaque.

Leave a Comment