0

I'm a beginner in Objective C and I have an issue between my Table View Controller and ViewController. When I click on the cell nothing happens, I don't go in my view controller to have more details about my cell.

I use a push segue and I don't forget to give it an identifier and to do this code part in my TableView:

(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"showDetails"]) {
        NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
        ViewController *destViewController = segue.destinationViewController;
        destViewController.details = data [indexPath.row];
    }
}

My link between my two views is between the cell prototype and the ViewController window.

チーズパン
  • 2,752
  • 8
  • 42
  • 63
LeBrequin
  • 137
  • 8

1 Answers1

2

in didSelectRowAtIndexPath:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        [self performSegueWithIdentifier:@"showDetails" sender:self];
    }

in prepareForSegue:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"showDetails"])
    {
        NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
    ViewController *destViewController = segue.destinationViewController;
    destViewController.details = data [indexPath.row];
    }
}
Anbu.Karthik
  • 82,064
  • 23
  • 174
  • 143
  • I think now he wants to go in the view however I have this error when I launch the app > 'Receiver () has no segue with identifier 'showDetails'' – LeBrequin Mar 07 '16 at 09:56
  • @Guillaume.M -- what is your segue connection name if it is wrong "showDetails" – Anbu.Karthik Mar 07 '16 at 10:00
  • When I click on the segue, I give it the identifier showDetails – LeBrequin Mar 07 '16 at 10:06
  • @Guillaume.M -- it is the small mistake , for your error see this http://stackoverflow.com/questions/20715462/receiver-viewcontroller-has-no-segue-with-identifier-addsegue/20715545#20715545, it helps you – Anbu.Karthik Mar 07 '16 at 10:06