0

At different places in my new ios App displays small MKMapView in which the scrolling and user interaction are disabled. Each map will always have a single custom annotation.

As shown in the screenshot, everything looks well. However, there is a small behaviour that I am not happy with. When the view or cell that contains the MKMapView is loaded, the map appears instantly but there is a small delay before the annotation is added to it. I think that this is due to the way the annotation work (like the UITableView).

Because my map will always contain a single annotation, is there a way to force it to be pre-loaded on the map before the map actually appear on screen. I don't want that small delay which is really annoying while the MKMapView is contained in a tableview cell which get reloaded while scrolling. Any other idea is welcome.

Thanks

iphone screenshot

yeesterbunny
  • 1,847
  • 2
  • 13
  • 17
philouuuu
  • 983
  • 1
  • 10
  • 19

3 Answers3

0

I dont have how to test it but what about set:

myPinView.animatesDrop = NO;

in your viewForAnnotation delegate, because default it is set to YES value.

edzio27
  • 4,126
  • 7
  • 33
  • 48
0

I dont know what you did exactly in code but perhaps it helps you.

- (MKAnnotationView *)mapView:(MKMapView *)mv viewForAnnotation:(id <MKAnnotation>)annotation
{
 MKPinAnnotationView* pv = (MKPinAnnotationView*)[mv dequeueReusableAnnotationViewWithIdentifier:reuse];
    if ( pv == nil )
    {
        pv = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:reuse] autorelease];   
        [pv setAnimatesDrop:YES]; // replace this line with the following line
        [pv setAnimatesDrop:NO];
    }

    [pv setAnnotation:annotation];

    return pv;
}
Amit Singh
  • 428
  • 3
  • 10
0

Why don't you just set your MapView to be hidden during initialisation then after your annotation is added, this method will be triggered:

- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views
{
    // reveal map
    mapView.hidden = NO;

    // -----------------------------------------------------------------
    // ALTERNATIVE WAY TO SHOW MAP VIEW WITH SMOOTH FADE IN
    //
    // if you want you can even animate the fading in of the 
    // note: this means you need to remove the above line
    // and you also need to set mapView.alpha = 0 during initialsation
    // instead of using mapView.hidden = YES
    // -----------------------------------------------------------------
    [UIView animateWithDuration:0.5 animation:^{ 
        mapView.alpha = 1;
    }];
}

(reference: http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKMapViewDelegate_Protocol/MKMapViewDelegate/MKMapViewDelegate.html#//apple_ref/occ/intfm/MKMapViewDelegate/mapView:didAddAnnotationViews:)

Zhang
  • 11,549
  • 7
  • 57
  • 87