首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >选择在MKPointAnnotation上无效

选择在MKPointAnnotation上无效
EN

Stack Overflow用户
提问于 2014-10-16 16:36:06
回答 1查看 219关注 0票数 0

在地图视图上显示感兴趣的位置,它是多个位置。

代码语言:javascript
复制
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上显示精确。在select pinpoints上,它不显示MKPointAnnotation的弹出框。

EN

回答 1

Stack Overflow用户

发布于 2014-10-16 18:04:56

您的代码非常完美,只需交换这一行

代码语言:javascript
复制
[mapView selectAnnotation:annotation animated:YES];
[mapView addAnnotation:annotation];

再运行一次,

代码语言:javascript
复制
[mapView addAnnotation:annotation];
[self performSelector:@selector(selectAnnoation:) withObject:annotation afterDelay:0.1];


- (void)selectAnnoation:(Annotation *)annotation {
    if(annotation)
    [mapView selectAnnotation:annotation animated:YES];
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26399744

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档