views:

279

answers:

1

Hi there! We have a MKmapView with a bunch of Image Annotation where each Image annotation responds to touch by overriding these methods of AnnotationView subclass:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

Our map region is updated using

[MkMapView setRegion:animated:]

whenever the new location is received and is far enough from the old location to make a difference.

What I noticed is that if we set animated flag to YES the touches on our annotation are rarely detected(probably due to the fact that main thread is busy animating between two map regions. When we set animated flag to NO, everything is fine, but map transition may(or may not) become jerky.

The question I have is whether this is an expected behavior of animated flag of [MkMapView setRegion:animated] function or whether there is a workaround for this issue.

Thanks in advance

A: 

Typically, the mapview being animated has its userInteractionEnabled property set to no during the animation. If you need to change this behavior, you should subclass the view and override the appropriate methods.

Alternatively, you could place a transparent view over the mapview for the duration of the animation to capture specific types of actions, such as respond to a double-tap to stop the change in region.

Chip Coons
Thanks for the pointer on userInteractionEnabled property changes, i couldnt find any info on why and when the system may decide to change this property though. However, i could potentially listen to its changes via KVO and switch it back when neccessary.
Vlad Gurovich
However, our app has a navigation toolbar with buttons above mkMapView. And the problem is, during the setRegion animations not only annotationviews are unresponsive to touches, but also the buttons on the toolbar. If [MkMapView setRegion:region animated:YES] blocks the main thread, it only makes sense that the buttons are non-responsive.
Vlad Gurovich