1

I'm developing a custom keyboard and based on Apple App Store Review guideline I have to provide a keypad for decimal and number pad :

Keyboard extensions must provide Number and Decimal keyboard types as described in the App Extension Programming Guide or they will be rejected

So I have to provide a keyboard for Decimal and Number Textfield, so how can I detect textfield type.

There is nothing about Number or Decimal Keyboard in App Extension Programming Guide so How detect which textfield I should load Decimal Keyboard or Number Keypad ?

Reza_Rg
  • 3,345
  • 7
  • 32
  • 48
  • What are you asking exactly? The sentence you quoted means that if you're developing a custom keyboard, you should provide a Number and Decimal keyboard. If you're developing an app with text fields, it's up to you to decide which keyboard to bring up on specific text fields. – p4sh4 Oct 10 '14 at 07:04
  • @p4sh4 Yes, That's exactly what I'm asking, I'm developing a custom keyboard and you based on the quoted sentences I have to provide a keyboard for Decimal and Number Textfield, so how can I detect textfield type. – Reza_Rg Oct 10 '14 at 07:19

1 Answers1

1

You can get the current keyboard type before your view appears like so (in Swift).

   override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)

        // Setup keyboard manager to correct type
        if let inputTraits = self.textDocumentProxy as? UITextInputTraits {
           let keyboardType = inputTraits.keyboardType
           let returnKeyType = inputTraits.returnKeyType
        }
    }

This from my project but reformatted for clarity. I also didn't compile it since it's such a simple example.

I've found it's good not to trust any extension API values until the view is visible or about to appear, but you could also try this in viewDidLoad()

SafeFastExpressive
  • 3,637
  • 2
  • 32
  • 39