2016-12-02 4 views
0

私は迅速な開発者で新しく、ネットで長い時間を探しています。しかし、使用しないでください。これを達成する方法を教えてください。スウィフトテーブルピンを選択してテーブルビューの詳細を表示する方法

tableview Cellの詳細を表示するマップピンを選択するとしたいと思います。この2枚のフォト

このよう

写真1

enter image description hereであると私は写真2のようになる画像を選択した場合。名前、住所、TelNumberラベルが

enter image description here

詳細が表示されます、私はこのコードを実行しようが、それでも

var dictRow = [String:String]() 
var dicRow = [String:[String:String]]() 
func getAddPin(){ 
     for index in arrTable{ 
      let Annotation = MKPointAnnotation() 
      let bLatitude = index["Latitude"] as! Double 
      let bLongitude = index["Longitude"] as! Double 
      Annotation.coordinate = CLLocationCoordinate2DMake(bLatitude , bLongitude) 
      Annotation.title = index["Name"] as? String 
      //writeing detail which pins is already make in map view 
      //I try use Annotation for key when I select pin can get value 
      PinName = [Annotation.title!]    //Name for key  
      dictRow["ClassType"] = index["ClassType"] as? String 
      dicRow[Annotation.title!] = dictRow  //write to dict   
      dictRow["City"] = index["City"] as? String 
      dicRow[Annotation.title!] = dictRow 
      dictRow["Area"] = index["Area"] as? String 
      dicRow[Annotation.title!] = dictRow 
      dictRow["Address"] = index["Address"] as? String 
      dicRow[Annotation.title!] = dictRow 
      dictRow["TelArea"] = index["TelArea"] as? String 
      dicRow[Annotation.title!] = dictRow 
      dictRow["Tel"] = index["Tel"] as? String 
      dicRow[Annotation.title!] = dictRow 
      myMapView.addAnnotations([Annotat 
} 
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) { 
     Pintouch = true 
     tableView2.isHidden = false 
     print(Pintouch) 
     myMapView.frame = CGRect(x: 0, y: 215, width: DeviceWidth, height: DeviceHeight - 330) 
     self.tableView2.reloadData() 
     } 
func mapView(_ mapView: MKMapView, didDeselect view: MKAnnotationView) { 
     Pintouch = false 
     tableView2.isHidden = true 
     myMapView.frame = CGRect(x: 0, y: 35, width: DeviceWidth, height: DeviceHeight - 150) 
    } 
func tableView(_ tableView: UITableView,cellForRowAt indexPath: IndexPath)-> UITableViewCell { 
     if Pintouch == true { 
      cell = tableView2.dequeueReusableCell(withIdentifier: "MyCell", for: indexPath) as! ClintTableViewCell 
      MapPinName = PinName[indexPath.item] 
      dictRow = dicRow[MapPinName]! 
      cell.MyCellName.text = MapPinName 
      cell.MyCellCT.text = dictRow["ClassType"] 
      cell.MyCellCIty.text = dictRow["City"] 
      cell.MyCellArea.text = dictRow["Area"] 
      cell.MyCellAddress.text = dictRow["Address"] 
      cell.MyCellTelArea.text = dictRow["TelArea"] 
      cell.MyCellTelArea.text = cell.MyCellTelArea.text! + "-" 
      cell.MyCellTelNum.text = dictRow["Tel"] 
} 

私がいることをどのように行うことができますが動作しませんでした?何か案は?歓声メイト!

答えて

1

あなたがテーブルビューセルのXIBとそのクラスを作成する必要があるすべて、あなたはそのテーブルビューセルのXIBをロードするために、このメソッドを使用する必要がある -

func mapView(_ mapView: GMSMapView, didTapInfoWindowOf marker: GMSMarker) { 
     let searchResultDict:SearchResult = self.searchListItems.object(at: index) as! SearchResult 
     let DetailScreenVC = DetailScreenVC(nibName: "DetailScreenVC", bundle: nil) 
     ScreenVC.organizationId = searchResultDict.organizationId 
     ScreenVC.countryId = searchResultDict.countryId 
     DetailScreenVC.stateId = searchResultDict.stateId 
     DetailScreenVC.activityId = searchResultDict.activityId 
     self.navigationController!.pushViewController(DetailScreenVC, animated: true) 
    } 

func mapView(_ mapView: GMSMapView, markerInfoWindow marker: GMSMarker) -> UIView? { 
    let infoWindow = Bundle.main.loadNibNamed("CustomInfoWindow", owner: self,options: nil)?.first! as! CustomInfoWindow 
     infoWindow.label.text = "\(marker.position.latitude) \(marker.position.longitude)" 
    return infoWindow 
} 

PS: - DetailScreenVCは、あなたのテーブルビューのセルペン先名

です
+0

回答ありがとうございました!しかし、私はGoogle Map SKDを使用しませんでした...あなたはこの問題を解決する別の方法がありますか? – Jeff

+0

mapView:(MKMapView *)mapView viewForAnnotation:(id )注釈 {}と - (void)mapView:(MKMapView *)mapViewアノテーションビュー:(MKAnnotationView)の代わりにMKmapデリゲートメソッドを使用できます。 *)ビューcalloutAccessoryControlTapped:(UIControl *)コントロール {} –

+0

Ps: - swiftに変換する –

関連する問題