Reputation: 133
I created a scene and tried to link the class to the scene and create a segue with the storyboard and use self.performSegueWithIdentifier("SegueID", sender: self)
and no matter what I did (i.e. clean build) I still got the same error "reason: 'Receiver () has no segue with identifier 'SegueID''"
I think the best way to solve this is to avoid the segue in this instance all together.
So is there a way to make a call from a view in the code to transition to another view without using segue in swift?
Edit I've tried all three ways but to no avail. The most common way of just creating a segue between two scenes in storyboard and giving it a name, in my case "Details", but the segue isn't recognized.
So I tried the next way of loading it from a nib and then pushing that nib onto the navigation stack, but when compile and build the program and I click on the button to present to new view controller, nothing happens except for the function println executing.
And trying to use the destination controller manually just didn't work. instantiateViewControllerWithIdentifier expects a string and complains that there are too many arguments in the call
Upvotes: 2
Views: 4456
Reputation: 22731
Your code doesn't work because you need to setup a segue in storyboards with a specific ID that you pass as an argument when you call performSegueWithIdentifier
. So, in your case, you need to create a segue with ID "SegueID"
, since that is the string that you are passing to that call.
If you don't want to do this using storyboards, you can still just use UINavigationController
directly (after all, a segue uses a UINavigationController
under the hood).
Then you just need to instantiate your destination view controller manually (e.g. by using
self.storyboard.instantiateViewControllerWithIdentifier(<your vc id from the storyboard>, animated:true)
or by loading it from a nib
init(nibName:bundle:)
and then push it onto the navigation stack using
self.navigationController.pushViewController(<the formerly instantiaded vc>)
Upvotes: 3