2015-10-07 78 views
0

我試圖在地圖上顯示地名名稱數組的結果。使用普通的針腳不是問題:它們顯示正常,點擊時,細節單元格將顯示該位置的名稱。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 
} 

(I與imageResize功能調整銷圖像)

該功能在改變的方面成功針:它確實成爲所需的圖像。但是,單擊這些圖像不會再顯示細節。

回答

2

好的我只需要在我的代碼中添加pinView.canShowCallout = true,我認爲它默認是真的,因爲它不是原始引腳所必需的。