Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use the system keyboard without a UITextView or UITextField

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!

like image 592
lol Avatar asked Feb 25 '23 04:02

lol


1 Answers

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.

like image 130
Bogatyr Avatar answered Mar 07 '23 01:03

Bogatyr