0

I have UIViewController with a button, button opens a firstTableViewController -> tabViewController (with 3 tabs) -> one of the tabs has a secondTableViewController -> UIViewController.

Everything is in storyboard.

In firstTableViewController the prepareForSeque works fine. I don't even have didSelectRow...

But on secondTableViewController the prepareForSeque doesn't fire. So I added didSelectRowAtIndexPath as follows. But still the prepareForSegue doesn't work.

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

-(void) performSegueWithIdentifier:(NSString *)identifier sender:(id)sender
{
    [self prepareForSegue:self.storyboard sender:self];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {


    //When a row is selected, the segue creates the detail view controller as the destination.      
    //Set the detail view controller's detail item to the item associated with the selected row.
NSLog(@"test");
    if ([[segue identifier] isEqualToString:@"ShowComment"]) {

    }
}
coder
  • 4,121
  • 14
  • 53
  • 88

1 Answers1

0

I found the issue. I did not have an identifier for the cell. Selected the Prototype Cells in the storyboard, in the attributes inspector -> identifier entered 'Cell1'.

In the code:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell1";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

    // Configure the cell...
    Note *note = [notes objectAtIndex:indexPath.row];
    cell.textLabel.text = note.title;
    return cell;
}

voila, it worked.

coder
  • 4,121
  • 14
  • 53
  • 88