Open salmankhann opened 11 years ago
I just reproduced the problem here... There definitely appears to be something going on. I'll try and take a look.
I think that the map is taking control of the swipe gesture. Do you think adding a thin UIView towards the left over the map would solve the problem?
@chemjournal I think there is probably a better solution than that. I'll try poking around.
So I'm not endorsing this as a solution, but it does work...
- (void)viewDidLoad{
[super viewDidLoad];
//I'm not endorsing this, but it works...
[[self.mapView.subviews[0] gestureRecognizers]
enumerateObjectsUsingBlock:^(UIGestureRecognizer * gesture, NSUInteger idx, BOOL *stop) {
[gesture setDelegate:self];
}];
}
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
CGPoint location = [touch locationInView:self.mapView];
CGRect boundingRect = self.mapView.bounds;
if([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]){
//Adjust the box to take into account the bezel
boundingRect.origin.x+=20;
boundingRect.size.width-=20;
}
return CGRectContainsPoint(boundingRect, location);
}
The only shady part is grabbing the MKMapView gesture recognizers, which you could make a bit more robust.
@kcharwood I tried this solution but when you try it on an iPhone, the map flickers every time you pan. I guess thats because the mapView's bounds is affected?
What I posted above does not affect the map view bounds. It simply does not forward the touch on the gesture if the touch is within 20 pixels of the side of the map view. I havent tested it on a device, but it runs fine in the simulator.
No idea why the map flickrs when you pan fast around the map. I've used this code and it works fine...
[self.view addSubview:[[UIView alloc] initWithFrame:CGRectMake(0, 0, 5, self.view.bounds.size.height)]];
I found a more elegant solution by simply tying together the UIGestureRecognizers so that the drawer's pan gesture supersedes the map's pan gesture.
See https://stackoverflow.com/a/23222175/428209 for a code example.
The problem I have is that I have a mapview occupying the whole screen in the center controller and I've set the OpenDrawerGestureModeMask on the left controller to MMOpenDrawerGestureModeBezelPanningCenterView but I still can't get the left drawer to slide in when I swipe from the bezel and the map moves instead. Is there something i'm doing wrong or is there a workaround?
Great work btw. Really impressive!