&#39;Receiver (<ViewController>) has no segue with identifier &#39;addSegue&#39;

穿精又带淫゛_ 提交于 2019-11-26 06:48:24

问题


I have a navigation controller that has a segue links between them called \"addSegue\". When I click on the tableView cell though the app crashes and I get the error below:

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

I don\'t think that I have any issues with my code. Here is the method in which I have the line 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


回答1:


I had this same problem and actually my problem was that I was calling

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

instead of

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

so check that you are calling correct performSegueWithIdentifier method :)




回答2:


use segue identifier in Push Method and give the proper connection

if you are using Identifier, then call this line where u need

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

Swift 2.X

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

Swift 3

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

Regarding the new screen you have added that way. In that screen, when you're finished and want to remove it, it's just:

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



回答3:


Hard to say for sure, but some other people have had similar problems:

  • In this question, the asker instantiated the storyboard with init instead of instantiateViewControllerWithIdentifier so the segue wasn't set up properly.

  • In this question, it was just something weird going on internally with xcode and the simulator, and running Product->Clean helped.

  • And of course, it's possible the segue name in the code doesn't match the segue name on the Storybord, but I'm guessing you've checked that a lot of times already!




回答4:


Check whether UIKIT being or not in header file. I unknowingly made new VC a subclass of View Controller.



来源:https://stackoverflow.com/questions/20715462/receiver-viewcontroller-has-no-segue-with-identifier-addsegue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!