2017-06-01 59 views
0

我正在使用xamarin ios。我正在使用MKMapView來顯示一些位置。我有一些任務和地點(經度,緯度)。我已經在Map上映射了位置,當用戶點擊註解點時,它顯示任務的描述。如何在單一點顯示多個註釋詳細信息?

但是在某些情況下,多個任務可以具有相同的位置,因此在這種情況下,用戶在註釋點單擊時,任務描述會逐個顯示。但我希望當用戶點擊註釋點時,該點的所有任務描述應該像列表一樣顯示。如何在Xamarin ios中可能?

回答

0

使用自定義標註視圖來顯示所有的任務點的描述:

public override MKAnnotationView GetViewForAnnotation (MKMapView mapView, NSObject annotation) 
{  
     if (annotation is MKUserLocation){ 
      return null; 
     } 

     //Use a custom annotationView instead, which inherited from MKAnnotationView, has a label to display description. 
     ACustomMKAnnotationView annotationView = mapView.DequeueReusableAnnotation (annotationId); 

     if (annotationView == null) { 
      annotationView = new ACustomMKAnnotationView (annotation, annotationId); 
     } 

     annotationView.descriptionLabel.text = "All the task description joined"; 
     annotationView.CanShowCallout = true; 

     return annotationView; 
} 

採取從參考:https://developer.xamarin.com/guides/ios/platform_features/ios_maps_walkthrough/