'Receiver has no segue with identifier' when identifier exists - ios

For an iOS app, I have a story board and multiple controllers, and a segue going from controller GameClass to controller SettingsClass. The segue, in view Controller GameClass has an identifier called GameToSettings:
However, when I want to call the segue from my GameClass:
[self performSegueWithIdentifier: #"GameToSettings" sender: self];
I get the error message
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<GameClass: 0xcf0c550>) has no segue with identifier 'GameToSettings''
I tried many tips I found in other articles (like renaming the storyboard, cleaning the project, changing simulator format, giving another name to the segue, ), but the issue keeps coming.
I've uploaded a version of my code here: http://www.petits-suisses.ch/Issue.zip.
Any suggestion of what I could continue trying ?Thanks.

You should not instantiate your view controller this way:
GameClass *myNewVC = [[GameClass alloc] init];
Instead, use
[[UIStoryboard storyboardWithName:#"storyboard name" bundle:nil] instantiateViewControllerWithIdentifier:#"vc identifier">]
Edit:
Take a look at https://github.com/mac-cain13/R.swift
It will allow you to instantiate it easily with autocompletion, type safe method: R.storyboard.main.myViewController

Related

Receiver has no segue with identifier in self.performSegue(withIdentifier, sender)

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.

Receiver has no segue with identifier, though the segue is actually declared

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.

Simple segue not working in xcode 7

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.

segue with correct identifier can not work

I've search almost every related question, but still can not find a clue...
Here is what I did:
1.Create a scrollView using storyboard.
2.Programticaly created 10 myController(which are UITableViewControllers) inside the scrollViewController, So I can use panGesture to switch between tables. and it's working fine.
3.Created a tableViewController using storyboard, set myController to be the corresponding view controller.
4.Embedded the tableViewController in navigation controller.
5.Control drag from tableViewController to a new view controller to create a push segue.
6.Setup segue identifier in storyboard.
The Problem is:
A. When try to segue programmaticaly: use [self performSegueWithIdentifier:#"test" sender:self]; in tableView:didSelectRowAtIndexPath: method.
The exception shows all the time:Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<MyTableViewController: 0x8b413c0>) has no segue with identifier 'test''
B. Than I tried prepareForSegue: but it has never been called.
C. I've checked the segue identifier...there is no problem at all.
What's happening here??? Anyone has any idea???
EDIT:
ScrollViewController and TableViewController are separately created on the same storyboard. no connection/segue between them.
PIC Updated.

segue button to next viewcontroller throws error in xcode

I have a tabbar ios application. I put (embed) NavigationController in one of the viewcontroller,then added one button and one new viewcontroller to pass. I dragged from button in first vc to new vc and select "push".
But following error message is thrown when I tab the button :
Terminating app due to uncaught exception 'NSGenericException', reason: 'Push segues can only be used when the source controller is managed by an instance of UINavigationController.'
I really don't understand because I have already a navigation controller and also not added any additional code yet.
Thanks for any help.
You may not use push segue with a button that you have created yourself. Try using Modal segue instead.

Resources