2013-10-14 30 views
0

单击单元后,它不会展开。 此问题在github上报告。 该问题仅针对iOS 7发生。在以前的版本中,一切正常。SDNestedTable扩展在iOS 7上不起作用

+1

这是题外话题,因为这不是问题。 – Kreiri

+2

我遇到问题并没有找到任何解决方案。我决定在这里发布一个问题和我的解决方案,因为很多人开始从堆栈溢出搜索 –

+3

为什么不是一个问题? – HamasN

回答

14

问题是扩展索引路径存储在NSDictionary中,其中NSIndexPath是关键。 在iOS 7方法-(CGFloat)tableView:heightForRowAtIndexPath:收到UIMutableIndexPath对象而不是NSIndexPath对象。因此,字典中的值无法检索。 下面是这个方法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]; 
} 

最简单的解决方法是创建一些关键的,将有来自indexPath值。并将是NSIndexPath班的成员。所以我改变了以下方法:

- (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]; 
}