简体   繁体   中英

Unwinding a segue on interface builder

I am not a regular user of interface builder but I have to use it for this project.

I am using storyboards and have managed to create a push segue from one view controller to another. Lets call it from A to B. Now I am trying to unwind that segue and return from B to A.

I do not need any information to be passed between controllers. I just need to go back.

I have a UIBarButtonItem navigation bar of B, and I have followed this tutorial .

I did this:

A) Created this method on B

- (IBAction)backToViewControllerOne:(UIStoryboardSegue *)segue {
        NSLog(@"from segue id: %@", segue.identifier);
}

B) The tutorial author says: "Link this method to a button in the view that you want to unwind from." but this cannot be done because the method has this parameter :(UIStoryboardSegue *)segue and Xcode will not allow a button to be linked to this method, because it expects the method to have this parameter :(id)sender . If I change the parameter to that, the triggered segue cannot be linked.

C) link the button to the green exit on storyboard, choosing the method on 1 . OK, did that.

Did all this and clicking on the button does nothing. Not even the action is triggered.

How do I solve that puzzle?

A method with with a particular signature, an IBAction with an argument of type UIStoryboardSegue, needs to be in the controller that you are unwinding to. That (and any other methods like it that you might have in other controllers) will show up in the exit button (of the controller you're unwinding from) when you control-drag to it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM