我正在使用ExpandableTableView。 在这里a link!
我怎么能得到它?
答案 0 :(得分:0)
ExpandableTableView.h
采用上一节变量
NSInteger presection;
在ExpandableTableView.m
中在- (id)initWithCoder:(NSCoder *)aDecoder
方法设置presection intial Value
presection=-1;
替换didSelectRowAtIndexPath
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// either expand the section or call the delegates method if already expanded
if ([_expandedSectionIndexes containsIndex:indexPath.section]) {
// we're already expanded
[self contractSection:presection]; // Contrace Previos Section
if (indexPath.row == 0) {
// close the section
[self contractSection:indexPath.section];
[super deselectRowAtIndexPath:indexPath animated:YES];
} else {
if ([_expandableDelegate respondsToSelector:@selector(tableView:didSelectRowAtIndexPath:)]) {
[_expandableDelegate tableView:self didSelectRowAtIndexPath:[NSIndexPath indexPathForRow:indexPath.row - 1 inSection:indexPath.section]];
}
}
} else if (indexPath.row == 0 && _ungroupSingleElement && [_expandableDataSource tableView:self numberOfRowsInSection:indexPath.section] == 1) {
if ([_expandableDelegate respondsToSelector:@selector(tableView:didSelectRowAtIndexPath:)]) {
[_expandableDelegate tableView:self didSelectRowAtIndexPath:indexPath];
}
} else {
if (presection!=-1) {
[self contractSection:presection];
}
presection=indexPath.section;
[self expandSection:indexPath.section];
[super deselectRowAtIndexPath:indexPath animated:YES];
}
}