adamhoracek / KOTree

MIT License
224 stars 52 forks source link

collapsing Cell which has more rows than tableView.visibleRows.Count #1

Open ghost opened 11 years ago

ghost commented 11 years ago

First of all, i'd like to thank you for this great component. and here is the bug;

If you expand a cell which has more ancestorSubItems than the visibleRows count of the tableView and try to collapse that cell back; it gives invalid update error.

'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (6) must be equal to the number of rows contained in that section before the update (14), plus or minus the number of rows inserted or deleted from that section (0 inserted, 7 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'

Also recreated this situation with your example code too (Just added more subItems and expanded/collapsed)

any idea how to fix that situation?

mikaelbartlett commented 11 years ago

cellForRowAtIndexPath return nil if the cell isn't visible.

use the array to fetch the right item instead.

fei545 commented 9 years ago

1、replace this method

2、change this method

3、add a property named row to KOTreeItem @property (nonatomic) NSInteger row;

chesteryeum commented 6 years ago

does anybody have a working version that fixes the "invalid number of rows" issue?