【发布时间】:2014-09-12 01:00:12
【问题描述】:
我正在尝试使用图像删除一些代表巴士站的图钉,当我添加图像时,它会更改图钉的位置。当我没有设置图像时,图钉会放在正确的位置。
func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {
if annotation is StopAnnotation {
let identifier = "stopAnnotation"
var pinView = mapView.dequeueReusableAnnotationViewWithIdentifier(identifier)
if pinView == nil {
//println("Pinview was nil")
pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: identifier)
pinView!.canShowCallout = true
pinView.image = UIImage(named: "stopIcon")
}
return pinView
}
return nil
}
示例
我尝试使用的图像:
谁能告诉我为什么会这样?我在此应用的 Obj-C 版本中使用完全相同的图像,一切正常。
【问题讨论】:
标签: ios swift mkannotation mkannotationview