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.
我在从Map视图到另一个View Controller创建segue时遇到问题。我希望用户单击注释并弹出另一个视图控制器。我在注释印刷机和下一个视图控制器之间创建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()
}
}
1 个解决方案
#1
You shouldn't override function performSegueWithIdentifier
just prepareForSegue
你不应该覆盖函数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
还有prepareForSegue方法,你的实现是错误的(如果你试图将一些参数传递到目标视图控制器)。你需要这样的东西
let vc = segue.destinationViewController as! MapRouteViewController
#1
You shouldn't override function performSegueWithIdentifier
just prepareForSegue
你不应该覆盖函数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
还有prepareForSegue方法,你的实现是错误的(如果你试图将一些参数传递到目标视图控制器)。你需要这样的东西
let vc = segue.destinationViewController as! MapRouteViewController