0

enter image description here

I have the UIView that contains tapGestureRezognizer. This view is added inside UIView in UICollectionViewCell (@IBOutlet weak var addViewContainer: UIView!) enter image description here

And then I'm filing the cell and placing this AddStoreView inside the cell (AddStoreView UI is created via nib) enter image description here

But when I tap on the AddStoreView object the method func tap(sender: AnyObject?) never calls. What I'm doing wrong?

Roman Volkov
  • 245
  • 1
  • 4
  • 12
  • if you put a breakpoint in your `AddStoreView.awakeFromNib` does it get hit? If you put touch event delegate methods inside your `AddStoreView` do they get called? – Putz1103 Jul 15 '16 at 15:44
  • Yes, AddStoreView.awakefromnib is called this code is executed let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(AddStoreView.tap(_:))) tapRecognizer.numberOfTapsRequired = 1 self.userInteractionEnabled = true self.addGestureRecognizer(tapRecognizer) but, when I tap on the view func tap(sender: AnyObject?) { isn't called – Roman Volkov Jul 15 '16 at 15:47
  • Add touch methods into that view. Make sure the touch events are not getting swallowed by another view. – Putz1103 Jul 15 '16 at 15:49
  • You are adding a new "AddStoreView" every time a cell becomes visible. That is definitely not correct, you should only do that when a new CollectionViewCell is created. Whether it will solve your problem, I don't know. – fishinear Jul 15 '16 at 16:06
  • Most likely, the "addViewContainer" has zero size, because it does not contain any view to start with. If it does not resize automatically, then you cannot tap on anything in it. – fishinear Jul 15 '16 at 16:13
  • Yeah, it's not correct, but it doesn't cause the problem. addViewContainer doesn't have zero size, it's size if defined in xib file for Cell class. – Roman Volkov Jul 15 '16 at 16:16
  • I see AddStoreView inside cell, but tapping the view doesn't call assigned method – Roman Volkov Jul 15 '16 at 16:17

0 Answers0