Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show the keyboard for a UIView

I have a UIView where I want to receive keyboard input. I have tried:

[self becomeFirstResponder];

But it doesn't work.

I could implement a 'dirty' workaround by having a hidden UITextField and forwarding the keystokes to my UIView - but how does my UIView receive the keyboard input directly?

like image 504
Ole Bjørn Setnes Avatar asked May 30 '12 15:05

Ole Bjørn Setnes


1 Answers

For a view to become first responder and show the keyboard, it must adopt and implement the UIKeyInput protocol. It must also override the canBecomeFirstResponder method to return YES.

See “Simple Text Input” in the Text Programming Guide for iOS.

like image 194
rob mayoff Avatar answered Sep 28 '22 00:09

rob mayoff