以编程方式继续不工作

segue programmatically not working

我有一个 segue 问题。我有 "next" 按钮:

- (IBAction)NextButton:(id)sender {
//...
[self performSegueWithIdentifier:@"adaugaScore" sender:self];
}

还有这个:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    if ([[segue identifier] isEqualToString:@"adaugaScore"])
    {
        ScoreViewController *scoreVC = segue.destinationViewController;
        scoreVC.score = [NSString stringWithFormat:@"%d",score];
    }
}

我的应用程序在这一行崩溃:

[self performSegueWithIdentifier:@"adaugaScore" sender:self];

出现此错误:

has no segue with identifier 'adaugaScore''

您需要将故事板中的故事板 id/name(adaugaScore) 设置到您的控制器。检查:What is a StoryBoard ID and how can i use this? 了解更多信息。

编辑: 要使用 segue 名称,请参考:How do i set a modal segue (programmatically) to a push segue

将 segue.identifier 设置为 adaugaScore。这是通过单击 segue 并在属性面板中设置标识符来完成的。