2016-10-21 1 views
2

私のアプリにMapViewがあります。ユーザーはそのMapViewにannotaion/pinを追加できます。私はうまくいきますが、新しいアノテーションデザインを追加することが可能かどうかを知りたいと思います。iOS 10のデフォルトアノテーション/ピンを追加するにはどうすればよいですか?

これは新しいピンです:

enter image description here

これは私のマップを示したものです:

enter image description here

これは私の注釈コードです:

let annotaion = MKPointAnnotation() 

このライン私の注釈をマップに追加します:

self.myMap.addAnnotation(self.annotaion) 

ありがとうございます。

+0

は、あなたのデプロイメント・ターゲットはiOSの10ですか? – kamwysoc

+0

はい。しかし私はiOS 9でこのアプリを作り始めました –

答えて

0

あなたはMKMapViewDelegatehttps://developer.apple.com/reference/mapkit/mkmapviewdelegate/1452045-mapview

実施例から

mapView(_ mapView: MKMapView, 
       viewFor annotation: MKAnnotation) -> MKAnnotationView? 

を実装する必要があります。

func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? { 
    let view = MKAnnotationView() 
    view.image = UIImage(named: "pin") 

    return view 
} 
+0

これを使うと:func mapView(_ mapView:MKMapView、viewFor注釈:MKAnnotation) - > MKAnnotationView? { のletビュー= MKAnnotationView() view.image = UIImage(命名: "ピン") リターンビュー}それは空のマップを返します..:/ –

+0

は "ピン" という名前の画像リソースがありますか? –

+0

あなたの問題を解決しましたか? –

関連する問題