Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to perform a segue

I would like implement a button to show another view. I have defined the destination ViewController in Storyboard & created a segue (of type push) and gave it an identifier.

In my root view controller

some method ...

        UIButton *btn = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        [btn addTarget:self action:@selector(showDetailView:) forControlEvents:UIControlEventTouchUpInside];

and

- (IBAction)showDetailView:(id)sender {
    [self performSegueWithIdentifier:@"ShowDetail" sender:sender];
}

however it doesn't do anything. I hear a Segue is an object. do I need to have a reference to it / synthesize it in my root view controller class? Any tip would be appreciated. Thank you.

like image 935
chizzle Avatar asked Oct 21 '11 06:10

chizzle


People also ask

How do you perform a segue?

Fortunately, it only takes two steps. First, select a segue in your storyboard, then go to the attributes inspector and give it a name such as “showDetail”. Technically the sender parameter is whatever triggered the segue, but you can put whatever you want in there.

How do I get a segue identifier?

Assigning an identifier for the segue:Select the segue, from the attribute inspector you'll see "Identifier" text field, that's it! make sure to insert the exact same name that used in performSegueWithIdentifier .

What is a relationship segue?

Relationships segues are different from the other segues in that they are resolved at build time. When a UITabBarController is loaded from a storyboard, all of its constituent view controllers are already 'inside' of it in the same NIB that represents the scene with the tab bar controller.


1 Answers

Edit:
Make sure your root view controller is embedded in a navigation controller. if it isn't, select your view controller in the storyboard designer and choose Editor->Embed In->Navigation Controller in the menu.

Original:
Double-check the Identifier (storyboard-code) and try setting sender to self. If that doesn't work you can create a Segue object yourself in code.

like image 123
Martin Ullrich Avatar answered Sep 25 '22 12:09

Martin Ullrich