0
我想從MapKit註釋(i)按鈕切換到UITableViewCell。要做到這一點,我用下面的代碼:從MapKit註解中接觸到UITableViewCell,並輕輕一點Firebase
func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
let annotation = view.annotation as! MKPointAnnotation
let uid = annotation.title
self.userkey = uid!
self.performSegue(withIdentifier: "showDetailFromMap", sender: self)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "showDetailFromMap" {
let detailTVC = segue.destination as! MediaDetailTableViewController
let value = self.userkey
print(value)
let ref2 = DatabaseReference.media.reference()
let query2 = ref2.queryOrdered(byChild: "uid").queryEqual(toValue: (value))
query2.observe(.childAdded, with: { snapshot in
let media = Media(dictionary: snapshot.value as! [String : Any])
print(snapshot.value)
self.media1 = media
})
detailTVC.media = media1
detailTVC.currentUser = currentUser
}
}
我在爲印刷(user.uid)製成的tableViewController的cellForRow print語句,這是拋出一個「意外發現無」的火力點後,打印語句引用沒有返回任何內容,所以我認爲這是從一個firebase錯誤開始的。 Firebase查詢未運行,因此媒體永遠無法獲得價值。我之前多次使用這種格式完成了成功的查詢,但現在無法正常工作。任何想法爲什麼?