Adding the control causes MKMapView/UIScrollView inside a UIScrollView to scroll the parent scrollview. #11

Closed
ChrisGrant opened this Issue Sep 17, 2012 · 4 comments

2 participants

@ChrisGrant

See this question on stack overflow:

http://stackoverflow.com/questions/12450539/mkmapview-panning-causes-parent-uiscrollview-to-scroll/

When you add a MKMapView (or UIScrollView) to a parent UIScrollView, the control hits the method:

  • (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { return YES; }

even if it the control isn't being used.

To replicate this, add a control to a simple one view window. Then add the following code to the viewDidLoad:

UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
[scrollView setAutoresizingMask:UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth];
// Make the content size large to allow scroll view to move
[scrollView setContentSize:CGSizeMake(1000, 2000)];
[self.view addSubview:scrollView];

double mapHeight = 200;

MKMapView *map = [[MKMapView alloc] initWithFrame:CGRectMake(0, 200, self.view.bounds.size.width, mapHeight)];
[scrollView addSubview:map];

This causes the bug to be reproduced. Contact me and I can send you a sample project which reproduces it.

@danielamitay

If you already have a sample project, would definitely appreciate it: daniel@amitay.us

I'll take a look as soon as I can.

@ChrisGrant

Thank you - I've mailed the sample project to you now. Let me know if you don't get it.

@danielamitay

Apologies for the delay. Basically, as a UIView category, DAKeyboardControl was intercepting some UIGestureRecognizer delegate methods from other views, even when you hadn't activated DAKeyboardControl on them.

Added a sanity check to prevent this interception. Thanks for pointing it out!

@ChrisGrant

Thanks for the fix! Appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment