使用没有UITextView或UITextField的系统键盘 [英] Use the system keyboard without a UITextView or UITextField

查看:110
本文介绍了使用没有UITextView或UITextField的系统键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要子类化UITextField或其他东西,并重新创建一个应用程序。 - 重新定义它是一个更抽象的文本输入小部件 - 真的我只需要一个UITextField生成的事件)或者我可以以某种方式显示键盘,接收它的事件,并自己解雇!



谢谢!

解决方案

你可以使用一个框架来实例化一个UITextField,屏幕到左边或顶部,并确保父视图设置为剪辑子视图),然后调用 [myTextField becomeFirstResponder] 显示键盘。将您的视图控制器设置为UITextFieldDelegate,并按照这种方式跟随文本的所有更改,使用您的自定义绘图代码回显该字符串。


I am creating an app with core graphics that needs to take text input and place characters at specific pixel offsets.

Do I have to subclass UITextField or something and re-invent the wheel (redefine it to be a more abstract text entry widget - really I only need the events a UITextField generates) or can I somehow show the keyboard, receive it's events and dismiss it myself!

Thanks!

解决方案

You could instantiate a UITextField with a frame that makes it invisible (off the "screen" to the left or the top for instance, and make sure the parent view is set to clip child views), and then call [myTextField becomeFirstResponder] to show the keyboard. Make your view controller a UITextFieldDelegate and follow all changes to the text that way, echoing the string using your custom drawing code.

这篇关于使用没有UITextView或UITextField的系统键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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