I have a MKMapView added to a UIScrollView. I thought that the expected functionality would be that panning the map would cause the map to move, but it’s parent UIScrollView would not scroll. i.e. if you were panning the map, the scrollview would stay in it’s current position.
This is my code:
scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.width, self.height)];
[scrollView setAutoresizingMask:UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth];
[self.view addSubview:scrollView];
double mapHeight = 200;
if([AppDelegate isRunningOniPad])
mapHeight = 400;
map = [[MKMapView alloc] initWithFrame:CGRectMake(0, 200, self.width, mapHeight)];
[map setExclusiveTouch:NO];
[scrollView map];
I’ve tried setting exclusive touch to YES and to NO, but it doesn’t seem to have any effect.
Is there a way to get the behaviour working so that panning the map will stop the UIScrollView from moving? I’ve tried changing map to a UIScrollView instead of an MKMapView too, but that had the same behaviour – so I doubt that this is MKMapView specific.
The expected outcome is correct, the scroll view should remain stationary when the Map View is touched, as this should receive the touch events before they are passed up the responder chain to the scroll view.
I have quickly tested the above code in an empty project, and this is working as expected with a couple of alterations to the creating of frame & sizes, iPad size detection, and adding the map as a sub-view of the scroll view.