【发布时间】:2015-10-07 10:08:26
【问题描述】:
我正在尝试在 MapView 上显示一系列地点名称的结果。使用常规图钉不是问题:它们正常显示,单击时,详细信息单元格会显示该地点的名称。
for var t = 0;t<self.parties2.count;++t {
var placeLatitude:CLLocationDegrees = self.parties2[t].latitude
var placeLongitude:CLLocationDegrees = self.parties2[t].longitude
var placeLocation = CLLocationCoordinate2DMake(placeLatitude, placeLongitude)
var annotation = MKPointAnnotation()
annotation.coordinate = placeLocation
annotation.title = self.parties2[t].name
self.mapView.addAnnotation(annotation)
}
然后我用这个函数改变了引脚的外观:
func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {
let identifier = "pin"
var view: MKAnnotationView
view = MKAnnotationView(annotation: annotation, reuseIdentifier: identifier)
var image = UIImage(named: "symbol.png")
image = self.imageResize(image!, sizeChange: CGSizeMake(20, 20))
view.image = image
return view
}
(我使用 imageResize 函数调整 pin 图像的大小)
这个函数成功地改变了大头针的外观:它确实变成了想要的图像。但是,单击这些图像不再显示详细信息。
【问题讨论】:
标签: ios swift mkmapview mapkit