Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

performSegueWithIdentifier produce no segue with identifier error

I am having hard time getting performSegueWithIdentifier to work. I keep getting

"Receiver (<UINavigationController: 0x1e59a9d0>) has no segue with
 identifier 'identA'"

What I did is that:

  1. Step: created a single view application and added a label - "View controller A" to the view controller.
  2. Step: Dragged and dropped another View Controller and added a label - "View controller B" to the new view controller.
  3. Step: Chose view controller A and performed Editor->embed in->navigation controller
  4. Step: wired View controller A to View controller B with push segue with Identifier "identA" Like this: wiring the seque

  5. Step: added a call to performSegueWithIdentifier onView controller A's ViewDidLoad. Like this:


- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.navigationController performSegueWithIdentifier:@"identA" sender:self];
    // Do any additional setup after loading the view, typically from a nib.
}

What have I done wrong???

like image 701
Yony Avatar asked Sep 27 '13 00:09

Yony


2 Answers

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];
like image 152
stefanB Avatar answered Nov 15 '22 22:11

stefanB


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.

enter image description here

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...

like image 21
Mike Gledhill Avatar answered Nov 15 '22 21:11

Mike Gledhill