单击注释时从地图视图中创建一个segue

时间:2015-05-04 20:09:34

标签: ios iphone swift mapkit mapkitannotation

我在从Map视图创建segue到另一个View Controller时遇到问题。我希望用户单击注释并弹出另一个视图控制器。我在注释印刷机和下一个视图控制器之间创建segue时遇到问题。我将我的segue从地图视图命名为导航视图Controller'annotationPress'。每当我点击地图上的注释时,我都会得到一个全黑的新视图控制器。任何建议将不胜感激。

    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

1 个答案:

答案 0 :(得分:1)

您不应仅仅performSegueWithIdentifier

覆盖功能prepareForSegue

您的实现错误的prepareForSegue方法(如果您尝试将一些参数传递到目标视图控制器)。你需要这样的东西

let vc = segue.destinationViewController as! MapRouteViewController
相关问题