【问题标题】:can't link a button to EXIT icon无法将按钮链接到 EXIT 图标
【发布时间】:2017-08-08 22:03:42
【问题描述】:

我正在学习如何创建 unwind segue。我创建了两个 VC,“ViewoController”和“MessageViewController”。第一个包含一个按钮,而后者嵌入在 NavigationController 中,它有两个 barButtons“取消”和“保存”。

据我所知,要创建展开转场,“MessageViewController”中的“取消”和/或“保存”按钮必须链接到其 ViewController 中的“MessageViewController”中的 EXIT 图标。

我遇到的问题是,当我无法将 barButton 链接到 EXIT 图标时

请告诉我如何将 barBurron 链接到 EXIT 图标,以便调用“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.
 }

【问题讨论】:

    标签: ios objective-c segue uistoryboardsegue unwind-segue


    【解决方案1】:

    您的方法签名不太正确。为了让 Xcode 将其识别为 Exit / Unwind Segue,它需要返回 IBAction

    改成:

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

    应该可以解决你的问题。

    【讨论】:

      猜你喜欢
      • 2016-02-16
      • 1970-01-01
      • 1970-01-01
      • 2012-10-01
      • 1970-01-01
      • 2015-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多