0

I'm having trouble accepting two gestures simultaneously across my sibling views. The view structure is as follows.

Superview
 |
 |--> ChildView1 (UITableView)
 |
 |--> ChildView2 (UIView).. Partially overlaps ChildView1

When I do a pan gesture on ChildView2, I would like that to pass through to ChildView1 so that the UITableView scrolls properly. However, when I do a LongPress gesture on ChildView2, I would like that to be properly recognized within ChildView2.

The closest question (and answer) I've seen is this. However, unlike that question, where ChildView1 has to handle the passed gesture, I would like the UITableView to handle the gesture and scroll as if it was scrolled directly on the view. Is that possible?

Thanks for any insights.

aek8
  • 319
  • 1
  • 8
  • 22
jayOrange
  • 123
  • 1
  • 9

1 Answers1

0

Create a subclass of UIView and add it as the class for childView2

class customView:UIView
{
   override func point(inside point: CGPoint,with event: UIEvent?) -> Bool
   {
     return false
   }
}
Shehata Gamal
  • 98,760
  • 8
  • 65
  • 87
  • That helps with scrolling ChildView1, but the gesture (long press) on ChildView2 will then no longer be recognized. – jayOrange Feb 14 '18 at 16:42
  • manage it's turn on/off by declaring a var in that custom class – Shehata Gamal Feb 14 '18 at 16:43
  • I would need to turn it off (pass the point to ChildView1) by default, and only turn it on when it's potentially a long press gesture. However if it's off by default, the long press gesture state won't ever change state, since all the touches are passed to ChildView1. Hence I won't have a chance to turn the var on. Again, to clarify, I would like to recognize both gestures (long press on ChildView2, and scroll on ChildView1) simultaneously. – jayOrange Feb 14 '18 at 17:41