Use the system keyboard without a UITextView or UITextField

你离开我真会死。 提交于 2019-12-10 07:14:16

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/4933389/use-the-system-keyboard-without-a-uitextview-or-uitextfield

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