3

So I have got this scenario:

-NavigationController
 -PageViewController
  -MapViewController
   -UIView
    -MKMapView (Full Screen)
  -OtherViewController

So basically, I want it to switch pages (viewcontrollers) when catching the UIScreenEdgeGesture. But having the map in one of them, this doesn't work properly.

I have researched a lot (!) about this but still haven't found the right solution.

I believe that the correct approach here is to delegate this gesture to the nextResponder in the hierarchy.

So I have successfully captured the gesture when the user swipes on the left edge of the screen.

Right now my issue is I can't manage to pass the gesture to the UIView (MKMapView.superview). I have two questions :

// 1. How to do it // 2. Is this the right approach?

Let me know your thoughts on this one please!

EDIT 1: Adding some code and Images of story board

UIScreenEdgePanGestureRecognizer *popRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:[self.view superview] action:@selector(handlePopRecognizer:)];
popRecognizer.edges = UIRectEdgeLeft;
popRecognizer.delegate = self;

[self.mapView addGestureRecognizer:popRecognizer];

enter image description here

EDIT 2: I want this behaviour : Use UIScreenEdgePanGestureRecognizer without moving MKMapView

But when the gesture is recognized, I want it to switch to the page on the left (OtherViewController)

FINAL EDIT: THE workaround that I've come up with consists in putting a clear view on top of the map, leading to the desired behaviour. Not happy with the solution, but it works for now.

enter image description here

Community
  • 1
  • 1
jonypz
  • 1,515
  • 1
  • 20
  • 35

1 Answers1

0

When you create your gesture, make the target the superview, and call the method in the superview for the action, something like:

    UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:[self.view superview] action:@selector(swipeHandler:)];

Don't know if MKMapView.superview would work, that depends on if MKMapView is an instance. Hard to know what you're referring to without code.

Owen Hartnett
  • 5,925
  • 2
  • 19
  • 35
  • There isn't much code to add. I have tried your approach unsuccessfully yet. I am trying to understand which method to call so that the pagecontroller handles the gesture – jonypz Dec 09 '14 at 22:57
  • I am using the default pageviewcontroller so I guess I should call pageViewController:viewControllerBeforeViewController: . But I guess the target is not right. When I print self.view.superview, it returns null. – jonypz Dec 09 '14 at 23:07