0

After clicking on a cell it doesn't expand. The issue is reported on github. The issue occurs only for iOS 7. On previous versions everything works fine.

Sviatoslav Yakymiv
  • 7,887
  • 2
  • 23
  • 43

1 Answers1

14

The issue is that expanded index paths are stored in NSDictionary, where NSIndexPath is key. In iOS 7 method -(CGFloat)tableView:heightForRowAtIndexPath: receives UIMutableIndexPath object instead of NSIndexPath object. So value from dictionary can't be retrieved. Here is this method in SDNestedTableViewController.m:

- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    int amt = [[subItemsAmt objectForKey:indexPath] intValue];
    BOOL isExpanded = [[expandedIndexes objectForKey:indexPath] boolValue];
    if(isExpanded)
    {
        return [SDGroupCell getHeight] + [SDGroupCell getsubCellHeight]*amt + 1;
    }
    return [SDGroupCell getHeight];
}

The simplest solution is create some key that will have values from indexPath. And will be member of NSIndexPath class. So I've changed this method in following way:

- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSIndexPath *indexPathKey = [NSIndexPath indexPathForRow:indexPath.row inSection:indexPath.section];
    int amt = [[subItemsAmt objectForKey:indexPathKey] intValue];
    BOOL isExpanded = [[expandedIndexes objectForKey:indexPathKey] boolValue];
    if(isExpanded)
    {
        return [SDGroupCell getHeight] + [SDGroupCell getsubCellHeight]*amt + 1;
    }
    return [SDGroupCell getHeight];
}
Sviatoslav Yakymiv
  • 7,887
  • 2
  • 23
  • 43