0

I am having trouble creating a segue from my Map view to another View Controller. I want the user to click an annotation and have another view controller pop up. I am having trouble creating the segue between the annotation press and the next view controller. I named my segue from the map view to the navigation view Controller 'annotationPress'. Whenever I click the annotations on the map, I get a new view controller that is all black. Any advice would be appreciated.

    func mapView(mapView: MKMapView!, annotationView view: MKAnnotationView!, calloutAccessoryControlTapped control: UIControl!)
    {
//        performSegueWithIdentifier("annotationPress", sender: view)
    }


    override func performSegueWithIdentifier(identifier: String?, sender: AnyObject?) {
        println("segueing...")
        if identifier == "annotationPress"
        {

        }

    }
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        if segue.identifier == "annotationPress"
        {
            println("hello")
            var vc = MapRouteViewController()

        }
    }

enter image description here

applejuiceteaching
  • 1,473
  • 3
  • 13
  • 25

1 Answers1

1

You shouldn't override function performSegueWithIdentifier just prepareForSegue

Also the prepareForSegue method your implementation is wrong (if you are trying to pass some arguments into destination view controller). You need something like this

let vc = segue.destinationViewController as! MapRouteViewController
Stefan Salatic
  • 4,513
  • 3
  • 22
  • 30
  • and i think you should not create a segue from the mapview to the detailviewcontroller (does that work at all?) but from the viewcontroller that contains the mapview to the detailviewcontroller! – André Slotta May 04 '15 at 20:30