Simple segue not working in xcode 7 - ios

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.

Related

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.

Error after segue to Storyboard Reference

I segue from one Storyboard where the View Controller is written in Objective C to another Storyboard where the View Controllers is written in Swift 2 and it goes through fine.
However, when I click fire the next segue in the second Storyboard, I get the following error:
*** Terminating app due to uncaught exception 'NSGenericException', reason: 'Could not find a navigation controller for segue 'record'. Push segues can only be used when the source controller is managed by an instance of UINavigationController.'
This is the code that calls the next segue in Swift 2
self.performSegueWithIdentifier("record", sender: nil)
The initial view in the second Storyboard is embedded in a Navigation Controller as well.
Also worth noting, I tried without the first storyboard and my app going directly to the second storyboard, and it finds the segue fine.
Any ideas on what could be causing the problem?
Choose the segue, go to its Attributes inspector and change the Kind from push to Modal. Let the presentation and Transition remain default.
This will work fine for you.
But if you want the segue of kind 'Push' then the first View controller which is written in Objective-C should be embed in Navigation Controller.

'Receiver has no segue with identifier' when identifier exists

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

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.

Error - Receiver has no segue with identifier 'detailLoad'

I know this question has been asked before but I have not found a solution to the problem.
I have two ViewControllers in IB and they are connected with a segue I want to fire manually. The segue is connected from the ViewController to the destination ok and the identifier is identical to the one in the code, I have copied and pasted, yet when I try to segue it crashes with 'NSInvalidArgumentException', reason: 'Receiver () has no segue with identifier 'detailLoad''.
- (void)stuff
{
NSLog(#"Tap");
[self performSegueWithIdentifier:#"detailLoad" sender:self];
}
Above is the code I use for the segue, yes I know it's called "stuff" but this is a test project not an actual project.
As i say the segue is named correctly and is all connected properly but it still gives this error as in it cannot find the segue. The project is set up for iOS 6. I have set up NSLogs in prepareForSegue but this is not fired as the error seems to be in the performSegueWithIdentier line.
Any ideas as to why?
Thanks
I had the same problem under iOS 6. I had been invoking the deprecated call presentModalViewController prior to the segue "being lost". Replacing that with the now preferred presentViewControllerAnimated the issue went away.

Resources