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.
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.
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.
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.
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.
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