Prevent custom keyboard in textfield

后端 未结 4 1944
粉色の甜心
粉色の甜心 2021-01-04 06:55

I was experimenting with how a custom keyboard affects my app. I installed Swype on my iPhone 6.

I find that in some of my views where I have custom inputView prop

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-04 07:34

    Using the answer from Pablo Ezequiel Romero as a starting point, I was able to get things to work for me. Essentially, rather than using a UIViewController for the custom keyboard, use a UIInputViewController and put your controls inside the UIInputViewController's inputView. Then, assign the inputView of your UITextField or UITextView to the inputView of the UIInputViewController.

    If you're using auto layout, you need to make sure that you set everything properly and make sure to set an initial height constraint on the inputView and set its priority below the max 999 level (I used 800). Any height will do; the system will replace your constraint with one of its own. The lower priority avoids auto layout conflicts. (For me, if I didn't include this constraint, the final view wouldn't have any height at all.)

    When I did all this, I was able to switch in and out of my (internal to the app) custom keyboard and any third-party keyboard extension.

提交回复
热议问题