Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add a Number and Decimal keyboard into my Custom Keyboard on iOS8?

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?

like image 282
ababab5 Avatar asked Sep 30 '22 16:09

ababab5


People also ask

How do I customize my Iphone Keyboard?

Navigate to Settings > General > Keyboard > Keyboards > Add New Keyboard and select AC Custom Keyboard. This will add it to the list of available keyboards. Go back to your app and bring up the keyboard by tapping the text view. Tap and hold the globe key and select AC Keyboard from the list that pops up.


1 Answers

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
    }
}
like image 196
Jordan H Avatar answered Oct 03 '22 01:10

Jordan H