I am learning how to create unwind segue. I created two VCs, „ViewoController“ and „MessageViewController“. The first one contains a button while the latter is embedded in a NavigationController and it has two barButtons „Cancel“ and Save“.
As far as I know, to create the unwind segue, the „Cancel“ and/or the „Save“ buttons in „MessageViewController“ must be linked to the EXIT icon in its ViewController which „MessageViewController“.
The problem I have is, when I can not link the barButton to the EXIT icon
please let me know how to link the barBurron to the EXIT icon in order to have the method "backToViewController" called
viewController.m
#import "ViewController.h"
#import "MessageViewController.h"
@interface ViewController ()
@property (strong, nonatomic) IBOutlet UIButton *buttonNext;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a
nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void) backToViewController:(UIStoryboardSegue *)segue {
}
@end
messageViewController:
#import "MessageViewController.h"
#import "ViewController.h"
@interface MessageViewController ()
@property (strong, nonatomic) IBOutlet UIBarButtonItem
*barButtonSave;
@property (strong, nonatomic) IBOutlet UIBarButtonItem
*barButtonCancel;
@property (strong, nonatomic) IBOutlet UITextField
*textFieldMessage;
@end
@implementation MessageViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
Your method signature is not quite right. In order for Xcode to recognize it for use as an Exit / Unwind Segue, it needs to return IBAction
.
Changing it to:
- (IBAction) backToViewController:(UIStoryboardSegue *)segue;
should solve your problem.