Search code examples
ios8ios-app-extension

iOS 8 custom keyboard extension UIKeyboardType


I'm building a iOS 8 custom keyboard and I'd like the change the layout of the keyboard based on the UIKeyboardType, however, reading the keyboard type in UIInputViewController is always 0. Any suggestions? Thanks in advance!

- (void)viewDidLoad
{
    [super viewDidLoad];

    NSLog(@"TextInputMode: %ld", self.textDocumentProxy.keyboardType);
}

Solution

  • Get the keyboardType in InputView Delegate Methods Instead of ViewDidLoad . Because you can't get the keyboardType until The keyboard is fully presented and the input object is activated .

    - (void)textWillChange:(id<UITextInput>)textInput {
    
        NSLog(@"TextInputMode: %ld", self.textDocumentProxy.keyboardType);
    
    }
    

    OR

    - (void)textDidChange:(id<UITextInput>)textInput {
    
        NSLog(@"TextInputMode: %ld", self.textDocumentProxy.keyboardType);
    
    }