开发者

How can I automatic show Title of place when pin?

开发者 https://www.devze.com 2023-03-01 04:13 出处:网络
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];

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;

    CLLocatio开发者_Go百科nCoordinate2D 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
}


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消