Iphone – Use the system keyboard without a UITextView or UITextField

cocoa-touchiphoneuikeyboarduikituitextfield

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!

Best Answer

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.