【问题标题】:'Receiver (<ViewController>) has no segue with identifier 'addSegue''Receiver (<ViewController>) 没有带有标识符 'addSegue' 的 segue
【发布时间】:2014-01-10 00:21:04
【问题描述】:

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

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

我认为我的代码没有任何问题。这是我有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];

}

Here is a picture of my storyboard

Here is an updated picture of my storyboard

【问题讨论】:

  • 检查您在 Storyboard 中提供的 Segue 标识符。
  • 清理项目并重试。
  • 您应该将您的故事板的图片发布到不需要他人许可的网站上。

标签: ios objective-c iphone swift uistoryboardsegue


【解决方案1】:

检查UIKIT是否在头文件中。我在不知不觉中让新的 VC 成为 View Controller 的子类。

【讨论】:

    【解决方案2】:

    use segue identifier in Push Method and give the proper connection
    

    如果您使用的是Identifier,请在需要的地方拨打此行

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

    Swift 2.X

    self.performSegueWithIdentifier("identifierName", sender: self)
    

    斯威夫特 3

    self.performSegue(withIdentifier: "identifierName", sender: self)
    

    关于您以这种方式添加的新屏幕。在该屏幕中,当您完成并想要删除它时,它只是:

    self.dismiss(animated: false, completion: nil)
    

    【讨论】:

    • 如何用这个方法将值传递给下一个视图控制器?
    • @Aniruddha -- 昨天我已经回答了你的问题,如果你不是我的,我解决了你的问题,你能把你的项目发到邮箱 karthik.saral@gmail.com
    • 我正在使用情节提要。我有 2 个 A 和 B 类。从 A,我想将值传递给 B。我就是这样做的,但它不起作用。 B *bb = [[B alloc]init]; b.strName = @"Abcd"; [self performSegueWithIdentifier:@"segueName" sender:nil];。请不要介意我无法将项目发送给您。
    • @Aniruddha - 它的 K 人,使用这个链接 stackoverflow.com/questions/19739037/… 否则说你的邮件 ID 我用不同的方法发送示例代码,k
    【解决方案3】:

    我遇到了同样的问题,实际上我的问题是我在打电话

    WRONG: [self.navigationController performSegueWithIdentifier:@"ShowVerify" sender:self];
    

    而不是

    CORRECT: [self performSegueWithIdentifier:@"ShowVerify" sender:self];
    

    所以检查你是否调用了正确的 performSegueWithIdentifier 方法:)

    【讨论】:

    • 不错,我就是这样
    • 谢谢,我有相反的情况。
    【解决方案4】:

    很难确定,但其他人也有类似的问题:

    • this question 中,提问者用 init 而不是 instantiateViewControllerWithIdentifier 所以 segue 设置不正确。

    • this question 中,发生了一些奇怪的事情 在内部使用 xcode 和模拟器,并运行 Product->Clean 帮助。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多