When I add a UILongPressGestureRecognizer
on my collectionView (I'm doing it like in this answer), the collection view stops highlighting cells as expected.
I'm handling the cell highlighting in my UICollectionViewCellSubclass, like it's explained in this answer:
- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];
if (self.highlighted) {
//Here I show my highlighting layer
}
else {
//Here I hide my highlighting layer
}
}
- (void)setHighlighted:(BOOL)highlighted
{
[super setHighlighted:highlighted];
[self setNeedsDisplay]; //This call draw rect and show/hide the highlighting layer
}
The problem seems to be that, when I add the UILongPressGestureRecognizer
gesture on the collection view, drawRect is not being called after setting highlighted to YES.
If I move the logic to show my highlighting layer in setHighlighted:YES
, I can't see the touching-feedback because setHighlighted:NO
its being called immediately after! (This happens only after adding the UILongPressGestureRecognizer
).
I've also tried to move the logic in touchesBegan
/touchesEnded
but then didSelectRowAtIndexPath:
doesn't work anymore.