The following works, but I'm not sure if this is the best way to do this. I think so.
Since everyone thumbViewshas a width kThumbSize, just check touchesEndedthat the x-coordinate of the locationInViewinstance UITouch(provided self.multipleTouchEnabled = NO) is less than or equal kThumbSize. This means that the strokes are completed inside thumbView. There is no need to check the y coordinate, because if touches are moved vertically tableView, containing thumbViews, scroll, and touches are canceled.
Do the following in ThumbView : UIView(whose instances are subzones a UITableView):
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"touchesEnded %@", touches);
CGPoint touchPoint = [[touches anyObject] locationInView:self];
if (touchPoint.x >= 0.0f && touchPoint.x <= kThumbSize) {
[(ThumbsTableViewCell *)self.superview.superview thumbTouched:self];
}
}
To register touches of only one thumbViewat a time, you also probably want to set self.exclusiveTouch = YES;in the initinstance method thumbView.
source
share