how to perform a segue

允我心安 提交于 2020-01-20 18:32:39

问题


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

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