I want to expand a UITableViewCell with this function, calling from didSelectRowAtIndexPath:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if(selectedCellIndexPath != nil &&
[selectedCellIndexPath compare:indexPath] == NSOrderedSame)
return 128;
return 43;
}
Clicking on a cell expands it, clicking on another cell collapses to old and expands the new cell. So far so good. But I also want to collapse the cell, when clicking on an expanded cell, and don’t know how?
As a bonus: the content of a not-expanded-cell is shown, overlapping the cell below. How can I prevent showing content that should be cropped by the size of a collapsed-cell?
Sounds like you just need to check in
didSelectRowAtIndexPath:…, ifindexPathis equal toselectedCellIndexPath, then setselectedCellIndexPathtonil.You didn’t provide that code, so I’m just guessing.