I'm working on a map which have some markers and I want to create an info view which will show an image and some text for each marker.
So, when I press the info button, it goes to a info view.
I have this on the code:
func mapView(mapView: MKMapView, annotationView: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
if control == annotationView.rightCalloutAccessoryView {
performSegueWithIdentifier("showInfo", sender: data)
}
}
But I want to pass the data from "locations" so I could show a image for each.
I need to do this in Swift.
Thanks a lot.
You should add this method to your class if you do not have and then pass your data to destination view's data.
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showInfo" {
let destination = segue.destinationViewController as! YourViewController
//this will execute before next ViewController's viewDidLoad method
destination.data = sender
}
}