How to add annotation AFTER the mapView has loaded?

Discussion in 'iOS Programming' started by WSD, Feb 16, 2010.

  1. WSD macrumors newbie

    Joined:
    Jan 6, 2010
    #1
    I need to add annotations long after mapView has loaded. I try to do the following:
    Code:
    //I call a method in mapView Controller
    -(void)showAnnotation {
    
    Basic_annotation *annotation = [[[Basic_annotation alloc] initWithCoordinate:myCoords title:@"alert"] autorelease];
    
    [mapView addAnnotation:annotation];
    }
    
    //This, in turn, calls the delegae method
    - (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation
    All seems well during the debugging but the annotation dont show on the map.
    I tried adding (to the showAnnotation method):
    Code:
    	[mapView setRegion:mapView.region animated:TRUE];
    	[mapView regionThatFits:mapView.region];
    But, still, no results.
    In the documenatation I see addAnnotation method called only during loading of the view. Is there a way to add annotation AFTER the view has loaded?
    Help is much appreciated...
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London

Share This Page