问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/7845832/how-to-perform-a-segue