Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unwind segue not work

I add a an action method to view controller and Ctrl-Drag the button to Exit icon in storyboard,and the unwind segue is created successfully.But when I touch the button, the unwind segue doesn't work(the current scene doesn't navigate to original scene) and the action method isn't triggered.I don't know why.

here is the action method

@interface HMCViewController2 : UIViewController
-(IBAction)return:(UIStoryboardSegue *)segue;
@end

@implementation HMCViewController2
...
-(IBAction)return:(UIStoryboardSegue *)segue{

}

@end

I upload the project to google drive.

like image 501
Han Pengbo Avatar asked Apr 06 '13 12:04

Han Pengbo


People also ask

How do you unwind segue?

In your storyboard, create an unwind segue by right-clicking a triggering object and dragging to the Exit control at the top of your view controller's scene.

How to unwind segue swift programmatically?

To add an unwind segue that will only be triggered programmatically, control+drag from the scene's view controller icon to its exit icon as shown in Figure 2. Choose an unwind action for the new segue from the popup menu. You must also give the segue an identifier so that it can be referenced by your code.

What is a segue Swift?

Swift version: 5.6. Segues are visual connectors between view controllers in your storyboards, shown as lines between the two controllers. They allow you to present one view controller from another, optionally using adaptive presentation so iPads behave one way while iPhones behave another.


1 Answers

You have put your unwind segue code in the wrong viewController. It should be located in the controller you wish to unwind TO, not the controller you are returning FROM.

like image 86
foundry Avatar answered Nov 02 '22 23:11

foundry