Objective C map view delegate viewForAnnotation for MKAnnotation gets just called after click

Posted by user1185486 on Stack Overflow See other posts from Stack Overflow or by user1185486
Published on 2012-08-29T21:36:53Z Indexed on 2012/08/29 21:38 UTC
Read the original article Hit count: 251

I have a simple Map view. It has a method

-(void)loadAndDisplayPois{
NSLog(@"loadAndDisplayPois");
 if(mapView.annotations.count > 0)
     [mapView removeAnnotations:mapView.annotations];
self.pois = [self loadPoisFromDatabase];
NSLog(@"self.pois.count: %i", self.pois.count);
[mapView addAnnotations:self.pois];
NSLog(@"mapView.annotations.count: %i",mapView.annotations.count);}

This method gets called, and I am sure that the method gets called because of the Log, after I downloaded data and saved it into the database. The class which handles the download executes after saving the data to the database [self.senderObj performSelector:@selector(loadAndDisplayPois)]; Where senderObj is the MapViewControlller. The count Log from the pois array shows 4 after the first time I clicked. But no Annotations on the view, because viewForAnnotation is not called (one Annotation in the array ( my current position)). After I execute the method again by clicking a TEST button shows everything on the map.

The viewForAnnotation method gets called after viewWillAppear and after I clicked the TEST button.

It is driving me nuts since 2 days. I cant anymore ...

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about mkmapview