ios - 在 map 注释 View 上设置标题和副标题

标签 ios mapkit mkannotation mkannotationview

我遵循了这个问题:iOS - MKMapView place annotation by using address instead of lat / long-为邮政编码创建 map 注释,而不是直接使用long / lat值。

这工作正常,但是我想设置字幕的标题和副标题

CLPlacemark *topResult = [placemarks objectAtIndex:0];
MKPlacemark *placemark = [[MKPlacemark alloc] 
placemark.title = self.business.businessName;
placemark.subtitle = self.business.phoneNumber;

由于标题和副标题是只读的,因此无法使用。如何更改以上内容,以便可以设置标题和字幕?

最佳答案

请改用MKPointAnnotation

示例代码:

CLPlacemark *topresult = [placemarks objectAtIndex:0];
MKPointAnnotation *annotation = [[MKPointAnnotation alloc] init];
annotation.coordinate = topresult.location.coordinate;
annotation.title = self.business.businessName;
annotation.subtitle = self.business.phoneNumber;
[self.mapView addAnnotation:annotation];

关于ios - 在 map 注释 View 上设置标题和副标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23444470/

相关文章:

ios - 检测用户是否移动了 map 或者它是否以编程方式发生 iOS Mapkit

python - 从网络服务器流式传输音频

ios - 如何使用缺少今天构建的列表在 iTunesConnect 中创建 "Build"记录?

ios - 将MapKit经纬度转为DMS格式

ios - Swift 中的完成处理程序

objective-c - 如何将 url 中的图像添加到 MKAnnotationView 以进行视网膜显示?

ios - 使用多个图钉在 map 中定位用户的位置

python - NodeJS APN 推送重复的通知

ios - 如何编译 `.framework`文件?

swift - 如何将 MKMapView 转为暗模式?