5

I created a custom keyboard in Swift but it was rejected from the App Store because: "keyboard extension does not include Number and Decimal types".

How can I add these two keyboards easily?

I tried to rebuild the original view but it doesn't work properly. I'm sure there is a solution to create 2 or 3 different views and switch between them.

How can I switch between keyboard types when the keyboard type changes?

Jordan H
  • 52,571
  • 37
  • 201
  • 351
ababab5
  • 284
  • 4
  • 14

1 Answers1

4

You can detect changes to the keyboard type in textDidChange. You need to get the UITextDocumentProxy then detect the proxy's keyboardType, and then you can do whatever layout changes needed.

override func textDidChange(_ textInput: UITextInput?) {
    // Called when the document context is changed - theme or keyboard type changes

    let proxy = self.textDocumentProxy as UITextDocumentProxy
    if proxy.keyboardType == UIKeyboardType.numberPad
        || proxy.keyboardType == UIKeyboardType.decimalPad {
        //add code here to display number/decimal input keyboard
    }
}
Jordan H
  • 52,571
  • 37
  • 201
  • 351