iOS Swift: Propagates Swipe Events from nester controller to underneath controller

87 Views Asked by At

I have a nested UIViewController that covers half of the screen.

Under this controller there is the parent ViewController.

I would like to propagate only the lateral swipe events to the bottom (parent) controller.

I think I should use the following func

override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
    return (my test)
    })
  }

but I also know that this func should be applied to a UIView, not to a UIViewController. So I'm stuck, and I don't know how to proceed.

1

There are 1 best solutions below

1
Shehata Gamal On

You can create

class SomeView:UIView {
   override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
     return  true/false
   }
}

and assign it to the child's vc'view in IB , you can also implement this inside the vc

override func touchesBegan(_ touches: Set<AnyHashable>, withEvent event: UIEvent) {
    var touch: UITouch? = touches.first
    //location is relative to the current view
    // do something with the touched point
    if touch?.view == childVC.view { 
    }
}

Edit:

to propagate swipe actions to parent add a delegate and swipe actions to the child and when triggered notify the parent with the delegate