获取有关地图视图选定注释的信息

发布于 2024-08-11 04:06:55 字数 255 浏览 3 评论 0原文

我在地图视图上有注释,并且每个标注上都有一个按钮。我需要做的是从这个标注中获取属性,即。标题,但记录这一行:

NSLog(@"%@", mapView.selectedAnnotations);

返回 这显然没有给我任何有用的信息...

我的问题是,如何访问所选注释标注的属性?

I have annotations on a mapview and a callout with a button on each. What I need to do is grab properties from this callout, ie. the title, but logging this line:

NSLog(@"%@", mapView.selectedAnnotations);

returns <AddressAnnotation: 0x1bdc60> which obviously gives me no useful info...

My question is, how can I access the properties of a selected annotation callout?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

迷离° 2024-08-18 04:06:55

就是这样

 for (id annotation in mapView.annotations) {NSLog([annotation title]);}

This is how

 for (id annotation in mapView.annotations) {NSLog([annotation title]);}
岁月静好 2024-08-18 04:06:55

这是我在annotationviewClick函数中所做的:

希望这有帮助

-(IBAction) annotationViewClick:(id) sender{

    [self.view addSubview:LoadingView];
    Annotation *ann = [myMap.selectedAnnotations objectAtIndex:([myMap.selectedAnnotations count]-1)];


    NSLog(@"Selected:%@", [ann tag]);

}

Here is what I did in the annotationviewClick function:

Hope this helps

-(IBAction) annotationViewClick:(id) sender{

    [self.view addSubview:LoadingView];
    Annotation *ann = [myMap.selectedAnnotations objectAtIndex:([myMap.selectedAnnotations count]-1)];


    NSLog(@"Selected:%@", [ann tag]);

}
满天都是小星星 2024-08-18 04:06:55

mapView.selectedAnnotations 返回注释数组。您应该访问其项目以获取信息。

mapView.selectedAnnotations returns an array of anotations. You should access its items to get info.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文