Reputation: 133
For some strange reason, Xcode
doesn't recognize my segue when I create it and use performSegueWithIdentifier("Details", sender: self)
.
But I was able to find a way around this by presenting the view controller with this:
let viewController:UIViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("DetailsViewController") as! UIViewController
self.presentViewController(viewController, animated: true, completion: nil)
How can I pass data from the MKAnnotationView
, to the new details view if I'm not using a segue
? (func prepareForSegue
requires a segue to pass data right?)
Upvotes: 0
Views: 97
Reputation: 104
On your segue not recognized issue -
Show/push segues have to be performed by a navigation controller.
Like Dhaval said, you don't have to use segues to pass data though. All you need is a public property/public method that you can use to pass the data.
Upvotes: 0
Reputation: 3205
// You have to make object of that DetailViewController(Class Name)
rather than viewController
let viewController:UIViewController = storyboard.instantiateViewControllerWithIdentifier("DetailsViewController") as! DetailViewController
// Then you can access variable of DetailsViewController
Like This:
viewController.parameter = whatever
self.presentViewController(viewController, animated: true, completion: nil)
Upvotes: 2