Reputation: 14864
I have a view controller with a number of subviews. When user clicks on the screen, I want to know which child view was touched. Is there a way to determine this?
-(void)touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event {
UIView *touchedView = ...
if(touchedView == self.importantView){
//do something cool.
}
}
Upvotes: 0
Views: 76
Reputation: 1316
Try this:
UITouch *touch = (UITouch *)[touches anyObject];
UIView *touchView = touch.view;
Upvotes: 1