user11124487
user11124487

Reputation: 53

How to handle dragging in a tableview with different row height in iOS?

When I tap ones on a row its height increases(to 200). when I tap again its height decreases to the default height(to 100).
I keep an array of selected rows. and in - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath I set the appreciate height based on weather they are selected or not.

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
// ...
if (listOfSelected && listOfSelected.count != 0 && [listOfSelected containsObject: sectionNumber]) {
     baseHeight = 200;
}

return baseHeight
}

This is ok, but when I drag them some problems are causes. like the row height which was 200 becomes 100 or vice a versa. I think thats because of wrong row number.
Is there any standard way to do this?

Upvotes: 1

Views: 185

Answers (1)

dahiya_boy
dahiya_boy

Reputation: 9503

As you said, I keep an array of selected rows, after completion of drag-drop of tableView cell you need to update your selectedRow array too because your cell index is changed its treating your work with the old index pattern.

Upvotes: 1

Related Questions