'Receiver(<ViewController>)没有带标识符'addSegue'的segue

Mic*_*hKE 11 iphone objective-c ios uistoryboardsegue swift

我有一个导航控制器,它们之间有一个名为"addSegue"的segue链接.当我点击tableView单元格虽然应用程序崩溃,我得到以下错误:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<MSAddFriendsViewController: 0x98cc340>) has no segue with identifier 'addSegue'
Run Code Online (Sandbox Code Playgroud)

我认为我的代码没有任何问题.这是我有这条线的方法showSegueWithIdentifier:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSMutableSet *selectedUsers = [NSMutableSet set];

[self.tableView deselectRowAtIndexPath:indexPath animated:NO];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];


cell.accessoryType = UITableViewCellAccessoryCheckmark;
PFRelation *friendsRelation = [self.currentUser relationforKey:@"friendsRelation"];
PFUser *user = [self.allUsers objectAtIndex:indexPath.row];
[friendsRelation addObject:user];
[self.currentUser saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
    if (error) {
        NSLog(@"Error %@ %@", error, [error userInfo]);

    }    }];

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

}
Run Code Online (Sandbox Code Playgroud)

这是我的故事板的图片

这是我的故事板的更新图片

oox*_*xio 16

我有同样的问题,实际上我的问题是我在打电话

WRONG: [self.navigationController performSegueWithIdentifier:@"ShowVerify" sender:self];
Run Code Online (Sandbox Code Playgroud)

代替

CORRECT: [self performSegueWithIdentifier:@"ShowVerify" sender:self];
Run Code Online (Sandbox Code Playgroud)

所以检查你是否正在调用performSegueWithIdentifier方法:)


Anb*_*hik 11

在此输入图像描述

use segue identifier in Push Method and give the proper connection
Run Code Online (Sandbox Code Playgroud)

如果您正在使用Identifier,请在您需要的地方拨打此线路

[self performSegueWithIdentifier:@"identifierName" sender:self];
Run Code Online (Sandbox Code Playgroud)

Swift 2.X

self.performSegueWithIdentifier("identifierName", sender: self)
Run Code Online (Sandbox Code Playgroud)

斯威夫特3

self.performSegue(withIdentifier: "identifierName", sender: self)
Run Code Online (Sandbox Code Playgroud)

关于新屏幕,你已经添加了这种方式.在那个屏幕上,当你完成并想要删除它时,它只是:

self.dismiss(animated: false, completion: nil)
Run Code Online (Sandbox Code Playgroud)


JKi*_*ian 6

很难说,但其他一些人也有类似的问题:

  • 这个问题中,提问者实例化了故事板, initinstantiateViewControllerWithIdentifier没有设置正确的segue.

  • 这个问题中,这只是内部使用xcode和模拟器的奇怪内容,并运行Product-> Clean帮助.

  • 当然,代码中的segue名称可能与Storybord上的segue名称不匹配,但我猜你已经检查过很多次了!