MKAnnotation nicht zeigen Legende auf MKMapView

Habe ich eine MKMapView und ich bin das hinzufügen von Anmerkungen wie diese:

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];
}

Den MKAnnotation's zeigen, bis auf die Karte einwandfrei, und ich kann diese auswählen, jedoch keine callout-bubble erscheint. Ich weiß, dass Sie richtig ausgewählt-Formular dieses

-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
    [view setCanShowCallout:YES];
    NSLog(@"Title:%@",[view.annotation description]);
}

Aber, dass nur druckt

Title:(null)

Bin ich mit der ARC, und ich habe die Einstellungen in meinem Ort Objekt als solches:

@property (nonatomic) CLLocationCoordinate2D coordinate;
@property (nonatomic,readwrite, copy) NSString *title;
@property (nonatomic,readwrite, copy) NSString *subtitle;

Was mache ich falsch/fehlt?
Danke.

Vor der addAnnotation Linie, können Sie NSLog pin.title und sehen, was es zeigt? Auch im Place-Objekt haben Sie überschreiben die description Methode durch eine chance und wenn ja, welcher code ist es?
Die NSLog(@"%@",pin.title); Nur zurück (null). Ich verstehe nicht, warum obwohl.

InformationsquelleAutor Amit Shah | 2011-11-20

Schreibe einen Kommentar