Objective C map view delegate viewForAnnotation for MKAnnotation gets just called after click
- by user1185486
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 ...