Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>To know when the user drags the map, you need a <a href="http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKMapViewDelegate_Protocol/MKMapViewDelegate/MKMapViewDelegate.html" rel="nofollow noreferrer">delegate on the MKMapView</a>, and respond to regionWillChangeAnimated and regionDidChangeAnimated. The documentation claims that these may be called multiple times during a drag, but I don't see that happening.</p> <p>However, see <a href="https://stackoverflow.com/questions/4118596/mkmapview-regiondidchangeanimated-not-always-called">this discussion of these delegate methods not being called reliably</a>.</p> <p><strong>Edit</strong>: my original answer suggested using Core Animation to fade the popover, but this isn't feasible. See the comments. Even if you get the popover's <code>contentViewController</code>, and get its <code>view</code>, and change that view's <code>alpha</code>, the popover leaves a shadow unless you go searching through the layer hierarchy. If at all possible, <code>dismiss</code> and <code>present</code> the popover instead. This may be less convenient than Core Animation, as you may need an <code>NSTimer</code> to control the delay before it is restored.</p> <p>For other views on top of map views, once you know when dragging is happening, use Core Animation to fade your popover out and back in again. Adjust the durations, delays and name of the view to fade to suit.</p> <pre><code>- (void)mapView:(MKMapView *)mapView regionWillChangeAnimated:(BOOL)animated; { [UIView animateWithDuration:0.25 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction animations:^ { [[self viewOnTopOfMapView] setAlpha:0.0]; } completion:nil]; } - (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated; { [UIView animateWithDuration:0.25 delay:2.0 options:UIViewAnimationOptionAllowUserInteraction animations:^ { [[self viewOnTopOfMapView] setAlpha:1.0]; } completion:nil]; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload