Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
So I subclassed UIViewController and in the nib I have a UIView, and in it a tableview. It is my understanding that both UIViewController and UIView are subclasses of UIResponder, so they should receive the - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
method.
However, this is not the case, and my view controller subclass is not receiving that method. I'd really like to not subclass the UIView, if that's allright.
I am trying to implement
this
, but my
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
[textfield resignFirstResponder];
Is not getting called.
It depends on where you touch. If you touch in the table view the touches are sent to the tableview, not the view controller. If you touch in a textfield that is in your view, the touches are sent to the UITextField itself. If you touch outside the tableview, outside the textfield but in the viewcontrollers' view then the view controller should get those touches.
–
Unfortunately, touchesBegan only takes place in the view, despite UIViewController being a subclass of UIReponder. The docs for touchesBegan say this.
Tells the receiver when one or more fingers touch down in a view or window.
–
–
–
–
Is the UIView you are talking about is one you have created, or are you using the one furnished with the UIViewController ?
Further more, if the click happen on the UITableView, you will have to subclass this to let your UIViewController know that a click occurred on the tableview...
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.