diff --git a/ExpandableTableView/Control/ExpandableTableView.m b/ExpandableTableView/Control/ExpandableTableView.m index b299ab1..d2dd095 100644 --- a/ExpandableTableView/Control/ExpandableTableView.m +++ b/ExpandableTableView/Control/ExpandableTableView.m @@ -360,6 +360,24 @@ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInte #pragma mark - #pragma mark UITableViewDelegateMethods +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { + if ([_expandedSectionIndexes containsIndex:indexPath.section] && indexPath.row != 0) { + if ([_expandableDelegate respondsToSelector:@selector(tableView:heightForRowAtIndexPath:)]) { + return [_expandableDelegate tableView:self heightForRowAtIndexPath:[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:heightForRowAtIndexPath:)]) { + return [_expandableDelegate tableView:self heightForRowAtIndexPath:indexPath]; + } + } else { + if ([_expandableDelegate respondsToSelector:@selector(tableView:heightForSection:)]) { + return [_expandableDelegate tableView:self heightForSection:indexPath.section]; + } + } + + return tableView.rowHeight; +} + - (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath { //[_expandableDelegate tableView:<#(UITableView *)#> indentationLevelForRowAtIndexPath:<#(NSIndexPath *)#> if (indexPath.row != 0 && [_expandedSectionIndexes containsIndex:indexPath.section]) { diff --git a/ExpandableTableView/Control/ExpandableTableViewDelegate.h b/ExpandableTableView/Control/ExpandableTableViewDelegate.h index d90431a..4390e5b 100644 --- a/ExpandableTableView/Control/ExpandableTableViewDelegate.h +++ b/ExpandableTableView/Control/ExpandableTableViewDelegate.h @@ -19,8 +19,8 @@ - (BOOL)tableView:(ExpandableTableView *)tableView canRemoveSection:(NSUInteger)section; -//- (CGFloat)tableView:(ExpandableTableView *)tableView heightForSection:(NSUInteger)section; -//- (CGFloat)tableView:(ExpandableTableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath; +- (CGFloat)tableView:(ExpandableTableView *)tableView heightForSection:(NSUInteger)section; +- (CGFloat)tableView:(ExpandableTableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath; - (NSInteger)tableView:(ExpandableTableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath; - (void)tableView:(ExpandableTableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath; - (void)tableView:(ExpandableTableView *)tableView willDisplayCell:(UITableViewCell *)cell forSection:(NSUInteger)section;