Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用Firebase从MapKit注释切换到UITableViewCell_Ios_Swift_Firebase_Mapkit - Fatal编程技术网

Ios 使用Firebase从MapKit注释切换到UITableViewCell

Ios 使用Firebase从MapKit注释切换到UITableViewCell,ios,swift,firebase,mapkit,Ios,Swift,Firebase,Mapkit,我正在尝试从MapKit注释(I)按钮切换到UITableViewCell。为此,我使用以下代码: func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) { let annotation = view.annotation as! MKPointAnnotation let ui

我正在尝试从MapKit注释(I)按钮切换到UITableViewCell。为此,我使用以下代码:

    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

    }
}

我在tableViewController的cellForRow中作为print(user.uid)生成了一个print语句,这将抛出一个“意外发现nil”。firebase引用之后的print语句没有返回任何内容,因此我认为这是从firebase错误开始的。firebase查询未运行,因此媒体从未获取值。我以前多次使用这种格式成功地进行查询,但现在它不起作用。知道为什么吗?

我将查询移到map函数中,并将self.performsgue包含在完成块中,现在可以使用了