Question

Hihi all,

My requirement is to hide the keyboard or picker when user tap out of my UITableViewCell (but still within the UITableView).

I have found some post about overriding hitTest by subclassing UIView, but my class is subclass of UIViewController, and I need the dismissModalViewControllerAnimated method, which makes me can't change the subclass to UIView, thus not able to override the hitTest.

Is there other alternative to achieve the above requirement? Please advice. Thanks in advance.

:)

Was it helpful?

Solution

You may be able to create an IBAction that sends the (id)sender and resignsFirstResponder add it to TouchUpOutside UITableViewCell in IB or you may be able to code it like:

 UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboard)];
 [self.tableView addGestureRecognizer:gestureRecognizer];

and add [specificfield resignFirstResponder]; to your dismissKeyboard field and make it into a void method.

That's what Dismiss keyboard by touching background of UITableView article says anyhow, and it seems similar to your problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top