I'm working in a new Swift project, where I'm trying the simple task of executing a segue whenever a button is pressed. However, whenever I try to trigger the segue, the following error pops up:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<Ma2Mi.LandingViewController: 0x7f99c65122b0>) has no segue with identifier 'showLogin''
Relatively simple, except for that there's actually a segue named showLogin:
(the top view controller is of type LandingViewController.)
This is how the segue is invoked:
loginButton.addAction {
self.performSegue(withIdentifier: "showLogin", sender: nil)
}
How is it possible that such a simple task is failing? Perhaps a bug, or something I overlooked?
Thanks.
Did you use the required init() function on the ViewController triggering the segue? I had the same issue until I removed it.
Related
I've only been programming for a month, and I am trying to cobble together a mockup and I keep getting the following error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<OutsizeMockup_0_1.HomeViewController: 0x13460f870>) has no segue with identifier 'testSegue''
I get this when I have my segue transition:
self.performSegue(withIdentifier: "goToProducts", sender: self)
within my buttonWasPressed method(which is called after my URLSession is created), but not when I call it within any other button that's not nested in Session. So I know the identifier is spelled correctly and under the right view controller class. I'll post my code below.
My project layout
First the browse button is pressed and the fetchDrop method is called:
HomeViewController where button is pressed
Then, the class that manages the url session is called: DropManager class with url session. Using this data, pM.initializeProducts is called, leading to the next file
Finally, buttonIsPressed is called here. And once it's called, the segue within the HomeViewController gets the error that I mentioned above
I'd be interested to know if there are any glaring issues with my code.
I'm getting this follow message when I try open a table item in my 'add' form to update it.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver () has no segue with identifier 'verBeneficioSegue''
Github with project: https://github.com/felipeejunges/MyBenefits
Segue:
My code:
When I was debbuging I got error in line 58.
P.S. I'm doing a project exercise for my post-degree in iOS.
I try to clean up project, restart Xcode, restart my Mac, but nothing worked.
From the crash the segue is inside vc named ListarBeneficiosTableViewController
ListarBeneficiosTableViewController: 0x7fbf6d510340>) has
no segue with identifier 'verBeneficioSegue'
and your vc shown in picture is named MyBeneficio ( it's a UITaBarController ) which isn't the same hence the crash
If your purpose is to add another tab to the tabs controller you should drag the segue from the tab to the listoVC and select viewControllers from the popup
Otherwise the segue origin should be ListarBeneficiosTableViewController and it's destination is another vc
You are saying
self.performSegue(withIdentifier: "verBeneficio", sender: beneficio)
in your ListarBeneficiosTableViewController class. This implies that your ListarBeneficiosTableViewController instance is loaded from the storyboard and in the storyboard it has a segue called "verBeneficio".
Okay, so let's look in the storyboard. When we do, we see that the "verBeneficio" segue does not come from the ListarBeneficiosTableViewController. It comes from the tab view controller.
Trying to move from my first ViewController to my second ViewController (both using same storyboard), using a segue. My first ViewController has two buttons, one that says "Male", one that says "Female" (I know, not everyone associates with one of these two), and I want either, once clicked, to move to the second ViewController. I drag/dropped the button into my code to get the following:
#IBAction func femaleButton(_ sender: AnyObject)
{
Globals.onboardingList.append("girl")
print("it's a girl!")
performSegue(withIdentifier: "femaleSegue", sender: self)
}
The Male button is identical. Using printlines I know that the program works until the "performSegue" line. I added visual segues and put their identifiers as maleSegue and femaleSegue. However, I am getting the following error:
Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[Train.SecondVC
_setViewDelegateContentOverlayInsetsAreClean:]: unrecognized selector
sent to instance 0x7fc482d02b00'
Thanks so much for any help!
In my case I got this error because I had made a custom ViewController class and mistakenly assigned it to the View in the Storyboard instead of the ViewController. Check your Storyboard View and ViewControllers for custom classes and make sure you've set them appropriately.
I can't figure the real problem as i believe you are not using the right identifier or made the segue connection from storyboard from the wrong view controller, however to make sure, please make one segue ctr + click on the button and drag it to the second screen and comment your action, if this works then remove that segue and the previous two segues and do it again but focus this time :)
Simple segue that has worked for months performed with this command:
[self performSegueWithIdentifier:#"ExpirationWarningSegue" sender:self];
now yields this error:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not perform segue
with identifier 'ExpirationWarningSegue'. A segue must either have a
performHandler or it must override -perform.'
What? It's a segue. I command-drag from one UIViewController to another in the storyboard. I'm not writing code for this. The segue is defined in the storyboard with this exact identifier.
Why does this happen now that I have upgraded to xcode 7 when it used to work just fine?
The error message tells you exactly what the problem is:
'Could not perform segue with identifier 'ExpirationWarningSegue'. A segue must either have a performHandler or it must override -perform.'
This is a custom segue. Therefore it must implement perform.
A cool feature of Xcode 7 / iOS 9 is that you can use a custom segue even where you have already specified a push (show) segue or a present (modal) segue. In that case, your perform must call super to get the original behavior.
See my comment here. It is a simple custom segue implementation in objC. Porting it to swift is trivial.
I have a app project I am working on. I created an unwind segue in my main view as
#IBAction func unwindToHomeScreen(segue:UIStoryboardSegue) {
}
It works from another view from the cancel button
however in the same view when I call the segue
self.performSegueWithIdentifier("unwindToHomeScreen", sender: self)
The app crashes with
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<TravelSave.AddVacationTableViewController: 0x7907f380>) has no segue with identifier 'unwindToHomeScreen''
Any suggestions?
Although you say in your comment, that you've "created the segue programmatically," from the screen cap you've posted in your question, it's clear that you've appropriately linked the segue to your cancel button within the storyboard. Within your storyboard, you need to add an identifier. Select the segue within the view controller scene, then add "unwindToHomeScreen" as an identifier:
The problem I was having was when I attached my Cancel button to my exit segue I did not put the identifier on the segue shown here