显示地图注释内的图像
使用下面的代码,我可以显示标题和副标题,并且我想在其中显示图像。这可能吗?如果是这样,请帮帮我。
MKPointAnnotation *aAnnotationPoint = [[MKPointAnnotation alloc] init];
aAnnotationPoint.title = @"Virginia";
aAnnotationPoint.subtitle = @"Test of sub title";
// Add the annotationPoint to the map
[myMapView addAnnotation:aAnnotationPoint];
Using the code below, I'm able to show the title and subtitle, and I want to show an image inside it. Is that possible? If so, please help me out.
MKPointAnnotation *aAnnotationPoint = [[MKPointAnnotation alloc] init];
aAnnotationPoint.title = @"Virginia";
aAnnotationPoint.subtitle = @"Test of sub title";
// Add the annotationPoint to the map
[myMapView addAnnotation:aAnnotationPoint];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您在注释的标注中显示标题和副标题(如果您使用的是图钉,则点击图钉时会出现灰色框)。如果是这样,标注有两个视图供您自定义(leftCalloutAccessoryView 和 rightCalloutAccessoryView(两者均在注释视图上设置)),
因此,如果您希望在点击图钉时图像出现在图钉上方的灰色框中,您可以执行以下操作因此,通过实现这样的委托方法来自定义注释视图:
但是,如果您想要的只是直接在地图上(而不是在标注中)显示大量图像,那么您可以使用相同的委托方法,设置注释视图的“image”属性,如下所示:
我希望能回答您的问题
I'm assuming that you are showing the title and subtitle in the callout for the annotation (the gray box that appears when you tap on the pin, if you are using a pin). If so, the callout has two views for you to customize (leftCalloutAccessoryView and rightCalloutAccessoryView (both are set on the annotation view))
SO if you want the image to appear in the gray box above your pin when you tap on the pin you can do so by customizing the annotation view by implementing a delegate method like this:
However, if all you wanted was to show a lot of images directly on the map (not in the callouts) then you could, using the same delegate method, set the "image" property of the annotation view, like this:
I hope that answers your question