I have a collection view, the datasource delegate works well, but UICollectionViewDelegate
:
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"didselect"); }
not get called, although i set the delegate (as i did with data source and it worked) I have to mention that my cell is loaded from a nib and is connected to a subclass of UICollectionViewCell
, anyway the cells do not respond to my touch. I enabled the user interaction in the UIImageView
that is in my cell.
also :
-(BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"this is caled"); return YES; }
is not getting called!
as I mentioned I did set:
[self.collectionView setDelegate:self];
and of course
<UICollectionViewDelegate>
also I don't have any touchBegan
override ..
UPDATE:
WEIRD! it only gets called if I long press! how can I fix this, I set delaysContentTouches to NO plus i don`t have any gesture recognizers implemented.
help please. thanks.
It looks like there is a UITapGestureRecognizer
somewhere up in the view hierarchy. By default, UITapGestureRecognizer
s consume the touch that they recieve, meaning that it is not passed to the views below it in the hierarchy. You need to find the rogue tap gesture and add this line
tapGestureRecognizer.cancelsTouchesInView = NO;
This will make it pass touches to views below it in the hierarchy, and hopefully solve your problem.
Looks like you've added TapGestureRecognizer somewhere and it prevents selecton of cell. Check them, that should be the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With