I'm currently developing an OpenGL ES game for the iPhone and iPod touch.
I was wondering how I can easily pull up the UIKeyboard? Is there an official, documented possibility to pull up a UIKeyboard without using a UITextField of UITextView?
If you subclass UIResponder, and declare the UIKeyInput protocol, the keyboard will appear when you become the firstResponder.
See the UIKeyInput protocol here.
One thing that tripped me up is that you'll need to override the canBecomeFirstResponder message.
It's not "officially" possible - you can't access the UIKeyboard object at all while staying within Apple's guidelines.
Creating an invisible UITextField, then calling [textField becomeFirstResponder]
would do the job - you could even subclass UITextField first, then override the delegate method textField:shouldChangeCharactersInRange:
to redirect the text input to where you want it to go.
It is indeed possible. I had myself struggled a lot with this. UIKeyInput protocol can be used to pull a keyboard without using a UITextField or UITextView. However it is only available in iOS 3.2 and above. Here is a tutorial on that.
Hope that helps.
I displayed the keyboard without any visible UITextField by positioning my textfield's frame out of the visible screen:
#define TEXT_FRAME -50,-50,0,0
self.textField = [[UITextField alloc] initWithFrame:CGRectMake(TEXT_FRAME)];
When I set the "first responder" the keyboard becomes visible without any visible input area:
// show the keyboard
[self.textField becomeFirstResponder];
I later dropped the idea. However, I don't know its conformance to the Apple guidelines.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With