2016-12-27 8 views
0

ピン位置のすぐ上にUIViewを表示し、ユーザーがマップを移動する場合、UIViewはピン位置の上にとどまります。私は説明文のバブルを使いたくない。他の方法はありますか? iOSの9でMKpointAnnotationピンの直上にUIViewを表示する方法

+0

これはあなたを助けますhttp://stackoverflow.com/a/38741017/6433023 –

答えて

1

我々はあなたがビューを作成し、

annotationView.detailCalloutAccessoryView = tempView 

として設定することができますdetailCalloutAccessoryView

という名前の新しいプロパティを持って、より詳細

MapKit iOS 9 detailCalloutAccessoryView usage

0

を取得するためのリンクをご確認くださいこのコードを試してみてください:

func mapView(_ mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView { 
    if (annotation is MKUserLocation) { 
     return nil 
    } 
    else if (annotation is YourAnnotationClassHere) { 
     let identifier = "MyCustomAnnotation" 
     var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: identifier) 
     if annotationView { 
      annotationView.annotation = annotation 
     } 
     else { 
      annotationView = MKAnnotationView(annotation, reuseIdentifier: identifier) 
     } 
     annotationView.canShowCallout = false 
     // set to YES if using customized rendition of standard callout; set to NO if creating your own callout from scratch 
     annotationView.image = UIImage(named: "your-image-here.png")! 
     return annotationView 
    } 

    return nil 
} 

これが主な目的です。これはすぐにこの答えの迅速なバージョンです:How to create Custom MKAnnotationView and custom annotation title and subtitle

希望!

+0

あなたのコードを投稿していないので、これは私があなたを助ける唯一の方法です –

関連する問題