I am currently working on a function where the user can tap on a maps annotation and be taken to another screen which will hold an image of that location. I am using Mapbox and the tapOnCallout function to segue to another view controller (imageLocationViewController) which will hold an image view.
The issue I am facing is letting this imageLocationViewController know which annotation has been clicked and therefore which image should be shown. I am using firebase to hold my data and within the annotation data I have a photoUrl which holds the relevant image.
I am currently able to print the relevant name of the annotation and photo Url when I am segueing. However, once I am within the imageLocation View Controller I believe I lose this data?
Does anybody know how I can pass this data into the new view controller so that I can pass the correct photoUrl into the image view.
This is my current code to segue to the imageLocationViewController.
func mapView(_ mapView: MGLMapView, tapOnCalloutFor annotation: MGLAnnotation) {
if let annotation = annotation as? SkateAnnotation {
self.performSegue(withIdentifier: "SkateImageSegue", sender: annotation.id)
print("YourAnnotation: \(annotation.photoUrl)")
}
}
Update ** Code for prepare for segue
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "EditSaveSpotSegue" {
let destination = segue.destination as! EditSaveSpotViewController
destination.parkId = sender as! String
}
}