performSegueWithIdentifier produce no segue with identifier error

百般思念 提交于 2019-12-05 01:17:20

You are calling performSegueWithIdentifier:sender: on self.navigationController but you setup the segue on View controller A:

wired View controller A to View controller B with push segue with Identifier "identA"

Try replacing:

[self.navigationController performSegueWithIdentifier:@"identA" sender:self];

with

[self performSegueWithIdentifier:@"identA" sender:self];

Just another suggestion (which saved me today)...

I've written many iPad & iPhone apps before, using Master-Detail pages, Navigation Controllers, etc, but today, I was stumped, as my simple two-screen iPhone app in XCode 5.1 refused to let me segue from one screen to another, within a UINavigationController.

It's another of those insane XCode bugs which made no sense. I could even create a new XCode project, and there, the same segue would work perfectly.

    [self performSegueWithIdentifier:@"segueTest" sender:nil];

Eventually, I found out the cause.

I had created a blank project in XCode, manually added a Storyboard to my project, but, I'd missed a step.

When you add a Storyboard yourself, you also need to go into your .plist file, and manually add a line telling your app the name of your main storyboard.

If you don't do this, strangely, your app will build successfully, it will run, you'll probably get your first screen to be displayed successfully... but then things (like finding segue names) will start to go wrong.

(Sigh.)

I hope this helps other XCode victims.

I need a beer...

Ok. Bit of a particular situation here, but in my situation I had a UISplitViewController set up in a new project. I wanted to perform a segue in the detail view controller after pressing a cell in the master table view. So in didSelectRowAtIndexPath: of the master table I performed

[[NSNotificationCenter defaultCenter]postNotificationName:@"userDetails"
                                                           object:nil];

and in the detail view in viewDidLoad: I added the observer and the instance method

[[NSNotificationCenter defaultCenter]addObserver:self
                                        selector:@selector(userDetailsShow)
                                            name:@"userDetails"
                                          object:nil];
-(void)userDetailsShow{
    [self performSegueWithIdentifier:@"userDetails" sender:nil];
}

When pressing the cell in the master view it would fire the method but do nothing. It turned out the problem was this:

I had left the default segue between the master table view cell and detail navigation controller active. In this case I didn't need it, so was able to delete it. Once deleting it it worked perfectly, as it should.
Hopefully I can now put this hair back in...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!