Search code examples
iosuinavigationcontrollerinteractivepopgesture

Forwarding touches to UINavigationController Interactive Pop Gesture Not completely Working


I'm trying to enable interactive pop gesture recogniser on my keyboard's accessory view. It does not work by default.

I passed an interactive pop gesture recogniser reference to my accessory view in order to forward its touch events to the recogniser

It particularly works: the navigation bar's title gets changed and the background of the accessory view reveals the previous view controller's view as if the transition did start. But the top view itself remains in place even if the gesture recogniser completes tracking.

I also tried to forward touch events to the navigation controller itself, to its view, to its top view controller and to their window. Nothing changed even after forwarding to all of them simultaneously

Any ideas what is missing?


Solution

  • It looks like it is not possible to reuse touch event instances in the responder chain. Once the sendEvent: on UIWindow is called, there is already a certain view owning the touch, so there is no cense in forwarding the UIEvent instances to other views or their gesture recognisers.

    However, the owning view can forward events to its nextResponder()s (e.g.: one of the gesture recognisers attached to this view or to one of the subviews of the view)

    The only chance to forward touches to another view (from another view hierarchy) or another view's gesture recognisers is before the UITouch object creation: i.e. on the UIWindow level during the hitTest:withEvent: method invocation, which calls the pointInside:withEvent: method

    Anyway I'm not sure whether it is possible to forward touches from one UIWindow to another. Will update the answer later

    http://www.russbishop.net/uitouchtypestylus?utm_campaign=iOS%2BDev%2BWeekly&utm_medium=email&utm_source=iOS_Dev_Weekly_Issue_225

    http://smnh.me/hit-testing-in-ios/