I'm using a SKSTableView and everything is working fine. I'm encountering an issue and can't find a way for it.
When I expand the first and second cell and then 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?
- (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];
}
This is how I solve my issue by calling the cellForRowAtIndexPath
in the didSelectSubRowAtIndexPath
.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
SKSTableViewCell *cell = (SKSTableViewCell *)[self tableView:_tableView cellForRowAtIndexPath:indexPath];
UITableViewCell *selectedCell = [self tableView:_tableView cellForRowAtIndexPath:indexPath];
_selectedCellTxt = selectedCell.textLabel.text;
}
- (void)tableView:(SKSTableView *)tableView didSelectSubRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *selectedSubCell = [self tableView:_tableView cellForSubRowAtIndexPath:indexPath];
_selectedSubCellTxt = selectedSubCell.textLabel.text;
UITableViewCell *selectedCell = [self tableView:_tableView cellForRowAtIndexPath:indexPath];
_selectedCellTxt = selectedCell.textLabel.text;
[self performSegueWithIdentifier:@"123" sender:self];
}