Reputation: 51
I have a view with an horizontal UICollectionView and two UIButton over it (fixed on the right and left side with 25% screen width).
My need is to scroll the collectionView when I start to drag over a button without loosing the tap gesture of the button.
I tried to override the touchesMoved of my button and send the touches and event to my collectionView but it doesn't work.
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[super touchesMoved:touches withEvent:event];
if (self.delegate && [self.delegate respondsToSelector:@selector(buttonDidTouchesMoved:withEvent:)]) {
[self.delegate buttonDidTouchesMoved:touches withEvent:event];
}
}
How can I do ?
Thanks.
Upvotes: 2
Views: 482
Reputation: 1611
subclass collectionView and override
- (BOOL)touchesShouldCancelInContentView:(UIView *)view {
if ([view isKindOfClass:UIButton.class]) {
return YES;
}
return [super touchesShouldCancelInContentView:view];
}
this solved my problem without loosing button tap.
Upvotes: 1