Here’s the scenario :
I have a UITableView, and a UITextView, added as subviews on a UIView.
When the user touches on any of the row, I want 2 things – resignFirstResponder for the UITextView and I want a pop type UIView added for the particular row.
That is done.
But I want the same functionality of resignFirstResponder for the UITextView when the user touches on the region of the tableView where there are no rows.
How to do that, is there any method of tableView, which lets me handle the touches on the region where there are no rows?
What u ll have to do is, create a custom
UITableView. (subclassingUITableView, by creating a new file)Override the ‘
touchesBegan‘ method of this custom tableView (which we can do becauseUITableViewis a subclass of aUIView)What we are doing is that, we are overriding how the
UITablViewcatches the touch. We can do that in thetouchesBeganmethod, asUITableViewis a subclass ofUIViewitself.So we can override the
touchesBeganmethod, to catch the touch on theUITableView, and then pass it further on to the super class of our custom tableView, which isUITableView, so that its ‘didSelectRow‘ method gets called.