Like this question I have a custom subclass of UITableViewCell with a UITextField. Its operating mode, with the exception of the keyboard, does not disappear when the user touches another table representing the table or something outside the table. I am trying to find a better place to find out when something outside the cell is touched, then I could call resignFirstResponder in the text box.
If the UITableViewCell can receive touch events for touches outside of its view, then it could just execute a resignFirstResponder, but I see no way to get these events in the cell.
EDIT: I tried this (below) in my subclass of UITableViewCell, but it does not work, I think, because touchhesBegan: withEvent: is not called if the event was handled by the control. I think I need to catch events before they somehow send a chain of defendants.
The solution I'm considering is to add the touchesBegan: withEvent: to method to the view controller. There I can send a resignFirstResponder to all the cells of the table that are visible, except the one in which the sensor was located (let it receive a touch event and process it itself).
Maybe something like this pseudo code:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { CGPoint touchPoint =
I am not sure if this is the best way to do this. It seems that some tableviewcell element cannot receive notification of events outside of events.
EDIT2: I thought I had an answer (I even posted it as an answer) using hitTest: withEvent: but that didn't work. It is not always called .: - (
source share