【问题标题】:unrecognized instance selector when opening segue打开 segue 时无法识别的实例选择器
【发布时间】:2014-07-05 15:39:01
【问题描述】:

我的应用目前具有以下布局:

导航控制器 -> UIViewController -> UIViewController -> UIViewController

我可以使用 segue 在控制器之间移动。

当我尝试在控制器之间传递一些数据时会出现问题。

这在从第一个视图控制器转到第二个视图控制器时有效。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    [self performSegueWithIdentifier:@"OpenMatch" sender:nil];

}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"OpenMatch"]) {
        NSIndexPath *indexPath = [self.matchesListView indexPathForSelectedRow];
        SingleMatchViewController *destViewController = segue.destinationViewController;
        MatchData *match = [self.matchesArray objectAtIndex:indexPath.row];
        destViewController.matchId = match.objectId;
        destViewController.matchTitle = match.matchDescription;
    }
}

现在从第二个到第三个 uiviewcontroller 我有类似的代码:

- (IBAction)openStats:(id)sender {
    [self performSegueWithIdentifier:@"OpenStats" sender:nil];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"OpenStats"]) {
        MatchStatsViewController *destViewController = segue.destinationViewController;
        NSLog(@"Opening stats for match : %@",self.matchId);
        destViewController.matchId = self.matchId;
        destViewController.matchTitle = self.matchTitle;
    }
}

它给了我这个错误:

 -[UIViewController setMatchId:]: unrecognized selector sent to instance 0x9ba72a0

目标控制器中的属性声明如下:

@property NSString*  matchId;
@property NSString*  matchTitle;

当最后两行被注释掉时,它就通过了。所以问题出在destViewController.matchId

你能帮我吗?

谢谢。

【问题讨论】:

    标签: ios uinavigationcontroller segue


    【解决方案1】:

    请注意,错误显示的是 [UIViewController setMatchId:],而不是 [MatchStatsViewController setMatchId:]。您可能忘记将第三个控制器的类更改为情节提要中的自定义类。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-07
      • 1970-01-01
      • 1970-01-01
      • 2019-08-28
      • 2012-07-24
      相关资源
      最近更新 更多