2016-11-10 11 views
1

ビューコントローラからデータを渡すためのソリューションがあることが分かります。しかし、私が午前問題は、私は地図のキットを使用していますし、私はそれが次のいずれかになりにピンがクリックされるか不明だ:View Controllerからデータを渡すMapKit

artworkPin = Artwork(title:"Wind Wand",locationName:"Majestic",discipline:"Statue", 
          coordinate:windwandcoord) 
artworkPin2 = Artwork(title:"Wind Wand2",locationName:" Not Majestic",discipline:"Statue", 
         coordinate:windwandcoord2) 

私はViewTwo(第2のビューコントローラ)のラベルをしたいですクリックされたピンの「情報」ボタンのタイトルとして表示されます。私は現在、次のように設定しています: var artworkPin:アートワーク!

ラベルはartworkPin(最初のピン)のタイトルとしてのみ読み込まれます。 接続コード、必要に応じて:あなたの助けを ViewTwo ViewControllerOne

感謝。

答えて

1

しかし、私が午前問題は、私は地図のキットを使用していますし、私はわからないよ ピンは、私は、これはのViewControllerの終わりで行くと仮定してい

func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) { 
    if control == view.rightCalloutAccessoryView { 
     if let artworkPin = view.annotation as? Artwork { 
      performSegue(withIdentifier: "no", sender: artworkPin) 
     } 
    } 
} 

override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 
    if let identifier = segue.identifier { 
     if identifier == "no" { 
      if let artworkPin = sender as? Artwork { 
       let ViewTwo = segue.destination as! ViewTwo 
       ViewTwo.artworkPin = artworkPin 
      } 
     } 
    } 
} 
+0

上でクリックされます1?編集:欠落していました}今テスト中... –

+0

'アートワーク'の宣言を教えてもらえますか? –

+0

今すぐテストし、情報ボタンは何もしません。クリックしても応答がない場合などです。 [更新されたView One](http://pastebin.com/pVJDh7b7)[Artwork.swift](http://pastebin.com/ysQ2Gqme) –

関連する問題