单击时,MapView自定义引脚不显示详细信息

时间:2015-10-07 10:08:27

标签: ios swift mkmapview mapkit

我正在尝试显示一系列地方的结果' 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函数调整图像大小)

此功能成功改变了引脚的外观:它确实成为所需的图像。但是,单击这些图像不再显示详细信息。

1 个答案:

答案 0 :(得分:2)

好的我只需要将pinView.canShowCallout = true添加到我的代码中,我认为默认情况下它是真的,因为原始引脚不需要它。

相关问题