I've got a MKMapView
and I'm adding annotations like this:
for (NSDictionary *tmp in response)
{
NSDictionary *places = [tmp objectForKey:@"place"];
NSDictionary *location = [places objectForKey:@"location"];
NSLog(@"long: %@ Lat:%@",[location objectForKey:@"longitude"], [location objectForKey:@"latitude"]);
float longitude = [[location objectForKey:@"longitude"] floatValue];
float latitude = [[location objectForKey:@"latitude"] floatValue];
CLLocationCoordinate2D locationco = {latitude,longitude};
NSString *titleString = [tmp objectForKey:@"name"];
Place *pin = [[Place alloc] init];
pin.coordinate = locationco;
pin.title = titleString;
pin.subtitle = @"A Location";
//NSArray *annots = [[NSArray alloc] initWithObjects:pin, nil];
//[map addAnnotations:annots];
[map addAnnotation:pin];
[[map viewForAnnotation:pin] setCanShowCallout:YES];
}
The MKAnnotation
's show up on the map fine, and I can select them, however no callout bubble appears. I know that they are being selected properly form this
-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
[view setCanShowCallout:YES];
NSLog(@"Title:%@",[view.annotation description]);
}
But that just prints out
Title:(null)
I'm using ARC, and I've got the properties set up in my Place object as such:
@property (nonatomic) CLLocationCoordinate2D coordinate;
@property (nonatomic,readwrite, copy) NSString *title;
@property (nonatomic,readwrite, copy) NSString *subtitle;
What am I doing wrong/missing? Thanks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With