views:

40

answers:

1

Hi all, I have a custom cell with a uitextfield inside. I want to hide the keyboard when the user touch the screen, I put a custom uibutton over my tableView, and in the touch up inside event, I call

-(IBAction) hideKeyBoard
{
    [customcell.textfield resignFirstResponder];
}

is it the right way to hide the keyboard with a uitableview because it don't works

A: 

No, a UIButton over your tableview is going to obstruct touches to the table, and views with alpha less than something like 0.1.

One method would be to subclass UITableView and override touchesBegan to detect a touch. From there, you have many options for how to deal with resigning first responder, notification, delegate method, reference to the text field.

Jerry Jones
another method would be to put the resignFirstResponder: in your didSelectRowAtIndex: delegate method but this could be iffy as well depending on the setup of your table view. (if for instance the user clicked on a button inside the table view or etc.)
Jesse Naugher