我遵循了这个问题: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/