Yes, you can. You need a variable containing the last selected row. For instance:
@property (nonatomic, assign) NSInteger selectedRow;
... Then we implement the method
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if(indexPath.row == self.selectedRow) { return 100.; } return 44.; }
and then update the method:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; if(self.selectedRow == indexPath.row) self.selectedRow = -1; else self.selectedRow = indexPath.row;
NOTE Initialize your self.selectedRow to -1 at the beginning of default 0 .
source share