Custom iPhone Keyboard

前端 未结 4 1131
情书的邮戳
情书的邮戳 2020-11-27 17:05

I need (i.e. a customer requirement) to provide a custom keyboard for the user to type text into both text fields and areas. I already have something that does the keyboard

4条回答
  •  粉色の甜心
    2020-11-27 17:14

    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:@"

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

提交回复
热议问题