DraggableCollectionView icon indicating copy to clipboard operation
DraggableCollectionView copied to clipboard

reloadData issue

Open WitzHsiao opened this issue 11 years ago • 8 comments

This is a very weird issue. It works fine in simulator, but not do the same in real iPhone.

I used [collectionView reloadData]; in didMoveItemAtIndexPath, but just the only cell which I moved refreshed. others cell didn't refresh.

please help me, thanks!

WitzHsiao avatar Feb 21 '14 04:02 WitzHsiao

iOS simulator doesn't reuse cells. I think the bug is hidden here.

wiruzx avatar Mar 19 '14 15:03 wiruzx

Alright, it's a little bit tricky, but works for me: The point is calling reloadData after some amount of time.

[collectionView performSelector:@selector(reloadData) withObject:nil afterDelay:0.3];

I don't know, why it works, maybe @lukescott will figure it out.

wiruzx avatar Mar 19 '14 16:03 wiruzx

The didMoveItemAtIndexPath feature was added by @ndlupine. Looking at it, it may be because didMoveItemAtIndexPath is called inside the completion handler of performBatchUpdates. That code probably should be inside the completion handler of animateWithDuration after invalidateLayout.

If someone wants to debug this and see if moving the code solves the problem, send me a pull request and I'll merge it.

lukescott avatar Mar 19 '14 19:03 lukescott

Nope, unfortunately it doesn't help. Exactly same behaviour.

wiruzx avatar Mar 20 '14 07:03 wiruzx

I found a very tricky thing, not sure if there is helpful. If I dragged it and then there got issue. and if I try press any cell a while, and just release it, don't move it. Then all cells are got reload.

WitzHsiao avatar Mar 21 '14 02:03 WitzHsiao

"Nope, unfortunately it doesn't help. Exactly same behaviour." ~wiruzx

Well, I have checked that too, and in my project it works as expected. Cells are reloaded properly.

mplackowski avatar Jun 20 '14 18:06 mplackowski

I see this problem if I flick an item to another location in the UICollectionView

martinlockett avatar Oct 29 '14 15:10 martinlockett

PR #42 fixes this (or will when it's merged)

martinlockett avatar Oct 29 '14 16:10 martinlockett