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 t
Save the index path as your selection instead of just the row. At the moment you are saving, say, row 2, and each section has a row 2, so that row is expanding in all sections.
You can compare index paths as follows:
if([indexPath1 isEqual:indexPath2])
// Do your thing
Better yet, UITableView
has an indexPathForSelectedRow
property, so you don't even need your own variable to keep track of this:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
int rowHeight;
if ([indexPath isEqual:tableView.indexPathForSelectedRow]) {
rowHeight = 185;
} else rowHeight = 44;
return rowHeight;
}
Check NSIndexPath. This object contains section as property.