0
votes

I am creating an app that pulls data from a server and pinpoints the different houses on a map. My problem is that it does display the annotations but when I click on them they do not respond - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view

I put my annotations in an array by:

int s;
self.mapAnnotations = [[NSMutableArray alloc] init];

for(s=0; s < numberOfAnnotations; s++)
{
    //NSDictionary *dict2 = [parser objectWithString:[[arrayOfResults objectAtIndex:0] description]];

   CLLocationDegrees daLong = [[[[[arrayOfResults objectAtIndex:s] objectForKey:@"map"] objectForKey:@"longitude"] description] floatValue];
   CLLocationDegrees daLat = [[[[[arrayOfResults objectAtIndex:s] objectForKey:@"map"] objectForKey:@"latitude"] description] floatValue];

    /*self.customAnnotation = [[BasicMapAnnotation alloc] initWithLatitude:daLat andLongitude:daLong];
    [self.mapView addAnnotation:self.customAnnotation];*/

    BasicMapAnnotation *m = [[BasicMapAnnotation alloc] initWithLatitude:daLat andLongitude:daLong];
    [self.mapAnnotations addObject:m];


}

[self.mapView addAnnotations:self.mapAnnotations];
NSLog(@"this number of annotations %d", [self.mapAnnotations count]);

I also noticed when I created a separate house to place on the map in my viewDidLoad:

self.normalAnnotation = [[BasicMapAnnotation alloc] initWithLatitude:38 andLongitude:-90.2045];
self.normalAnnotation.title = @"                                                         ";
[self.mapView addAnnotation:self.normalAnnotation];

It did work when I clicked on it, but the ones passed through the array didn't work. Can anyone help me figure out why it's not responding?

1

1 Answers

4
votes

That's because annotations should have a title for them to display a callout. In your for loop, set the title property like you did with self.normalAnnotation.title = @" ".