Xcode: Creating a custom keyboard just for my own app

放肆的年华 提交于 2019-12-10 15:15:33

问题


I am developing a math application. So I need a specific keyboard. I just could take the decimal pad, but there is missing the positive/negative ("+/-") button.

Now I want to program a custom keyboard or I would like to edit the decimal pad. What is more easy?

If I would program my own custom keyboard, can I use the custom keyboard extension or do I have to create a view with a button for every number in a separate view?

Because I need the keyboard on many different views: Is there a possibility to create a view with the keyboard and to display the keyboard-view in a container view on top of the other views?

Hope you get my struggle.


回答1:


Yes, you could just create your own keyboard class (inherits UIView) and .xib + Auto Layout will help you to make it more flexible. Lets say you using it inside UITextField, then you could set inputView of this Text Field, so there will be your custom keyboard than basic one.




回答2:


Now I want to program a custom keyboard or I would like to edit the decimal pad. What is more easy?

The custom keyboard will be easier, since you can't access the decimal pad since it's private api.

If I would program my own custom keyboard, can I use the custom keyboard extension or do I have to create a view with a button for every number in a separate view?

I am not sure of your use of keyboard extension, I think your referring to an App Extension, in which case you should review the Custom Keyboard section. If you want to build a keyboard just for your app look at the 'Custom Views For Data Input' section of the Text Programming Guide for iOS.

Either way you will lave to create a button for each character your keyboard will shown.

Because I need the keyboard on many different views: Is there a possibility to create a view with the keyboard and to display the keyboard-view in a container view on top of the other views?

If you create a custom view for text input you would typically assign the custom view as the input view of the UItextField or UITextView your using. This will display your custom view where the keyboard would normally be. If you desire a different layout then you will have to handle the relationship between your text input view and your custom keyboard view.



来源:https://stackoverflow.com/questions/28656725/xcode-creating-a-custom-keyboard-just-for-my-own-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!