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];
}
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 :)

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)
Hard to say for sure, but some other people have had similar problems:
In this question, the asker instantiated the storyboard with
init
instead ofinstantiateViewControllerWithIdentifier
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!
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