I have 2 views. View 1 is superview and i added tap gesture in superview. View 2 is Collectionview and when I click on collectionview cell both event didSelectItemAt in Collectionview and tap gesture in superview called.How can disable tap gesture in supperview when I click on collectionview cell?
Asked
Active
Viewed 2,154 times
-1
-
Do you have code that can help us duplicate things? – Jan 22 '18 at 02:53
1 Answers
3
You can try to set userInteractionEnabled
to false
on your parent view.
E.g view.userInteractionEnabled = false
Docs at userInteractionEnabled
--UPDATE
You can implement gestureRecognizer delegate,a nd then check if it is your view that called on touch
property;
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
if touch.view == {{youview}} {
return false
}
return true
}

belagoesr
- 168
- 6
-
But i need tapgesture when i click outside collectionviewcell and if you set userInteractionEnabled = false in parentview you can't click on collectionview because collectionvew inside parent view – Le Bao Jan 22 '18 at 03:08