I have a UITableView with multiple sections. Each section has a section header (a custom view) is there an easy way to detect when someone selects the section h
This isn't radically different than @rckoenes answer, but it does provide a more orthodox way of handling events on views rather than using invisible buttons.
I'd rather add a UITapGestureRecognizer to my header view instead of adding invisible buttons and resizing them:
UITapGestureRecognizer *singleTapRecogniser = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleGesture:)] autorelease];
[singleTapRecogniser setDelegate:self];
singleTapRecogniser.numberOfTouchesRequired = 1;
singleTapRecogniser.numberOfTapsRequired = 1;
[yourHeaderView addGestureRecognizer:singleTapRecogniser];
and then:
- (void) handleGesture:(UIGestureRecognizer *)gestureRecognizer;
You can use gesture.view to see which was touched. Then do whatever you need to do to find out which header it was (tags, data array lookup... )