如何创建自定义键盘 [英] How to create a custom keyboard

查看:131
本文介绍了如何创建自定义键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建自定义键盘/键盘,当有人点击UITextField时会显示?我想显示一个键盘,其中包含a,b,c,1,2,3和一个输入按钮,没有别的。键盘应该像标准键盘一样工作和行为(行为),但它看起来肯定会有所不同。



我找不到任何例子和我最好的发现是使用现有键盘过滤字符这是一个不可接受的解决方案。

解决方案

我认为你正在寻找 Text,Web,和编辑iOS编程指南


UIKit框架包括对自定义输入视图和输入附件视图的支持。当用户在视图中编辑文本或其他形式的数据时,您的应用程序可以用自己的输入视图替换系统键盘。例如,应用程序可以使用自定义输入视图从符文字母表中输入字符。您还可以将输入附件视图附加到系统键盘或自定义输入视图;此附件视图沿主输入视图的顶部运行,并且可以包含,例如,以某种方式影响文本的控件或显示有关文本的一些信息的标签。



<如果您的应用程序使用UITextView和UITextField对象进行文本编辑,要获得此功能,只需将自定义视图分配给inputView和inputAccessoryView属性即可。当文本对象成为第一响应者时显示这些自定义视图...







这可能是一个很好的介绍:自定义iOS键盘


How do I go about creating a custom keyboard/keypad that will show up when some one taps on a UITextField? I would like to display a keypad with a, b, c, 1, 2, 3 and an enter button, nothing else. The keypad should work and behave like the standard keyboard does (in behavior) but it will definitely look different.

I can't find any example and the best I've found is to filter characters with existing keyboard which is an unacceptable solution.

解决方案

I think you're looking for the "Text, Web, and Editing Programming Guide for iOS"

The UIKit framework includes support for custom input views and input accessory views. Your application can substitute its own input view for the system keyboard when users edit text or other forms of data in a view. For example, an application could use a custom input view to enter characters from a runic alphabet. You may also attach an input accessory view to the system keyboard or to a custom input view; this accessory view runs along the top of the main input view and can contain, for example, controls that affect the text in some way or labels that display some information about the text.

To get this feature if your application is using UITextView and UITextField objects for text editing, simply assign custom views to the inputView and inputAccessoryView properties. Those custom views are shown when the text object becomes first responder...


This might serve as a good introduction: customizing the iOS keyboard

这篇关于如何创建自定义键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆