crazyoxygen
crazyoxygen

Reputation: 716

How can I automatic show Title of place when pin?

I use geocode.And I try to set animate:YES everywhere and It didn't help.

here is my code

@map.m

mapView = [[MKMapView alloc] initWithFrame:self.view.bounds];
    mapView.delegate = self;
    mapView.mapType = MKMapTypeStandard;

    CLLocationCoordinate2D coord = {latitude: lat, longitude :  lon};
    MKCoordinateSpan span = {latitudeDelta: 0.001, longitudeDelta: 0.001};
    MKCoordinateRegion region = {coord, span};

    [mapView setRegion:region animated:YES];

    [self.view addSubview:mapView];

    MKReverseGeocoder *geocoder = [[MKReverseGeocoder alloc] initWithCoordinate:coord];
    [geocoder setDelegate:self];
    [geocoder start];

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark
{
    mapPlacemark=placemark;
    [mapView addAnnotation:placemark];
}

please help me or guide me.very thx . . . .

Thank you for answer. Here is the reesult of code

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark
{
    mapPlacemark=placemark;
    [mapView selectAnnotation:placemark animated:YES]; //Use this code.
    //[mapView addAnnotation:placemark]; << Don't use this code
}

Upvotes: 0

Views: 502

Answers (1)

visakh7
visakh7

Reputation: 26400

Try this to select the annotation.

[mapView selectAnnotation:yourAnnotation animated:YES];

Here is the Apple reference

Make sure you have enabled the callout for the pin.

Upvotes: 2

Related Questions