views:

470

answers:

1

Hi there,

I have a UIView subclass and I want the keyboard to appear when it is the first responder (so a backspace can be detected to "delete" the view). I have tried making my UIView subclass adopt the UITextInputTraits protocol but it seems that's not enough to make the keyboard appear. How can this be done? Or is it only possible for UITextFields & UITextViews.

Thanks,

Mike

+1  A: 

You can add a hidden UITextField as a subview to your UIView and then make that subview the first responder. That will bring out the keyboard and then you can use this delegate function to check for the backspace key:

- (IBAction)textChanged:(UITextField*)hiddenField

You have to put some text into the hidden text field, because "textChanged" will only get called if the text actually changed. And pressing the backspace key on an empty text field will not send an event.

Kobski