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.
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.
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 .
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With