<分区>
点击一个单元格后它不会展开。 该问题已在 github 上报告. 该问题仅在 iOS 7 中出现。在以前的版本中一切正常。
最佳答案
问题是扩展索引路径存储在 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];
}
关于ios - SDNestedTable 扩展在 iOS 7 上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19355182/
相关文章:
ios - 在 UISearchDisplayController 中检测对 "no displayed search results"的点击
ios - 在 Swift 中移动 UITableView 位置
iphone - UITableView 部分索引与搜索栏重叠
ios - 如何同步单元格展开/折叠和 Collection View 动画?
ios - 自定义表格 View 单元格未根据 Nib 调整大小
ios - 为 Xcode 6 iPhone 模拟器移除 iOS 8 UITableView 上的 SeparatorInset