MKMapView addAnnotation delay when dragging in a UIScrollView over the map
I'm working on an iPad application and I have a full screen MKMapView with a transparent UIScrollView (about 1/5 of the screen) on top of it. I'm adding annotations (map pins) to the map as you hori开发者_运维问答zontally scroll the UIScrollView, but I'm noticing that the pins don't actually drop onto the map until you release/stop dragging the UIScrollView.
I have also confirmed that the timing is as expected by adding the NSLog below. The console shows the "Adding pin" message when I scroll, but the pin doesn't get added until you stop dragging.
if(![myMap.annotations containsObject:item]) {
[myMap addAnnotation:item];
NSLog(@"Adding pin."); // Gets called when I would expect, but no pin drops
}
I'm sure that the map is doing something with the touches, but I'm not sure how to tell the map to ignore the touches in the UIScrollView above it ... or inversely, tell the UIScrollView NOT to pass the touches to the map below.
Any help would be apprciated.
I'm not sure how to tell the map to ignore the touches in the UIScrollView above it ... or inversely, tell the UIScrollView NOT to pass the touches to the map below.
Have you tried the three touch-related properties on UIViews? If you set your UIScrollView's .exclusiveTouch property to YES it will block touch events from being delivered to any other view in that window.
Or you could modify the mapview's .userInteractionEnabled property to NO. Either way, you'll block delivery of the touch events from the scroll view to the map view.
If those two properties don't work then your problem is probably something else unrelated to the touching inside the scrollview.
精彩评论