2017-08-08 60 views
0

我正在學習如何創建unwind segue。我創建了兩個VC,「ViewoController」和「MessageViewController」。第一個包含一個按鈕,而後者嵌入在NavigationController中,它有兩個barButtons「Cancel」和Save「。無法鏈接到EXIT圖標的按鈕

據我所知,要創建unwind segue,「MessageViewController」中的「Cancel」和/或「Save」按鈕必須鏈接到其ViewController中的「MessageViewController」中的EXIT圖標。

我的問題是,當我不能barButton鏈接到退出圖標

請讓我知道如何將barBurron鏈接到退出圖標,以便有方法「backToViewController」之稱

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

回答

0

您的方法簽名是不太正確。爲了讓Xcode識別它作爲退出/退繞Segue,它需要返回IBAction

將其更改爲:

- (IBAction) backToViewController:(UIStoryboardSegue *)segue; 

應該解決您的問題。