选择不适用于MKPointAnnotation

时间:2014-10-16 08:36:06

标签: ios iphone mkmapview mkpointannotation

在地图视图中显示感兴趣的位置,这些位置是多个位置。

MKPointAnnotation *annotation = [[MKPointAnnotation alloc] init];
    annotation.coordinate = CLLocationCoordinate2DMake([[[[InterestedLocationsAry objectAtIndex:i] objectForKey:@"Location"] objectForKey:@"latitude"] floatValue], [[[[InterestedLocationsAry objectAtIndex:i] objectForKey:@"Location"] objectForKey:@"longitude"] floatValue]);
    annotation.title = [[[InterestedLocationsAry objectAtIndex:i] objectForKey:@"Location"] objectForKey:@"name"];
    [mapView selectAnnotation:annotation animated:YES];
    [mapView addAnnotation:annotation];

它在mapview上的精确定位。 在选择精确点上,它不会显示MKPointAnnotation的弹出框。

1 个答案:

答案 0 :(得分:0)

您的代码非常完美,只需更换此行

即可
[mapView selectAnnotation:annotation animated:YES];
[mapView addAnnotation:annotation];

到此,再次运行,

[mapView addAnnotation:annotation];
[self performSelector:@selector(selectAnnoation:) withObject:annotation afterDelay:0.1];


- (void)selectAnnoation:(Annotation *)annotation {
    if(annotation)
    [mapView selectAnnotation:annotation animated:YES];
}