I have a UITableView with three sections (Friday, Saturday, Sunday) each with different data and a different number of rows. When selected, the selected row expands, but so do the rows in the other two sections with the same index. I only want the single selected row to expand.
Is there a way to also get the the section in my didSelectRowAtIndexPath method, and to use that in my heightForRowAtIndexPath method in order to keep all of the other rows at their unexpanded size?
The methods below are both in my UITableView subclass:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark;
customCell *cell = [tableView cellForRowAtIndexPath:indexPath];
//Close row if tapped a second time
if(self.currentSelection == indexPath.row) {
self.currentSelection = -1;
}
//Otherwise, expand row
else {
self.currentSelection = indexPath.row;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
int rowHeight;
if ([indexPath row] == self.currentSelection) {
rowHeight = 185;
} else rowHeight = 44;
return rowHeight;
}