I have a MapKit app with several annotations. When tapped the annotations go to the following page.
I want the 'Open in Maps' button to take the co-ordinates from the Annotation and the user's current location (already being tracked) and open the Map application giving directions to the Pin.
I have tried this using the following:
@IBAction func map_button(_ sender: AnyObject) {
let elephant = CLLocationCoordinate2DMake(-39.069150, 174.081657)
let elephant_place = MKPlacemark(coordinate:elephant)
let mapItem = MKMapItem(placemark:elephant_place)
let options = [MKLaunchOptionsDirectionsModeKey:
MKLaunchOptionsDirectionsModeDriving]
mapItem.openInMaps(launchOptions: options)
}
But once the MKAnnotation is clicked on it states this class is not key value coding-compliant for the key map_button.
I have attached my full code paste for the Info Page/Annotation Segue and Map View
Thanks for your help
In your case, seems you select only map_button. please select View controller and then check in connection inspector. there You may have a bad connection in your Controller. Delete this bad connection and then try