sakkaras / SKSTableView

An expandable table view.
MIT License
446 stars 115 forks source link

Selection cell issue - when first & second cell are expanded #28

Open LuaiKalkatawi opened 9 years ago

LuaiKalkatawi commented 9 years ago

I'm encountering an issue, when I expand the first and second cell and select from the first expanded sub row cell, I get the second row name with the first selected sub row name. What I should get is the first name with first sub row name instead. How I can fix this issue?

LuaiKalkatawi commented 9 years ago

My Code:

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

  SKSTableViewCell *cell = (SKSTableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
  UITableViewCell *selectedCell = [self tableView:_tableView cellForSubRowAtIndexPath:indexPath];
  _selectedCellTxt = selectedCell.textLabel.text;

  if ([cell respondsToSelector:@selector(isExpandable)]){

      if ([cell isExpandable])
      {
          NSLog(@"SELECTED Row %@", _selectedCellTxt);
      }

  else{
         _selectedCellTxt = selectedCell.textLabel.text
         [self performSegueWithIdentifier:@"123" sender:self];
    }
}

- (void)tableView:(SKSTableView *)tableView didSelectSubRowAtIndexPath:(NSIndexPath *)indexPath{

  UITableViewCell *selectedCell = [self tableView:_tableView cellForSubRowAtIndexPath:indexPath];
  _selectedSubCellTxt = selectedCell.textLabel.text;
  NSLog(@"SELECTED Sub Row %@", _selectedSubCellTxt);

  [self performSegueWithIdentifier:@"123" sender:self];
}