pronebird / UIScrollView-InfiniteScroll

UIScrollView ∞ scroll category
MIT License
1.06k stars 148 forks source link

Animation glitch when scrolling during content updates #34

Open pronebird opened 8 years ago

pronebird commented 8 years ago

Cells animate chaotically and content offset gets misplaced If user pans the view during the call of -finishInfiniteScroll. It seems like cells are being reused during beginUpdates and endUpdates animations and due to content offset changes, apply to wrong cells. I can reproduce it with self sizing cells only.

The quick fix is to forcefully cancel pan gesture recognizer before the call to pb_setScrollViewContentInset, however it's not optimal and has side effects.

BOOL shouldCancelPanGestureRecognizer = (self.isTracking || self.isDragging);
if(shouldCancelPanGestureRecognizer) {
    BOOL wasEnabled = self.panGestureRecognizer.enabled;
    self.panGestureRecognizer.enabled = NO;
    self.panGestureRecognizer.enabled = wasEnabled;
}
pronebird commented 8 years ago

It does not look as bad on iOS 10 beta, so things are getting better!

KoD4K commented 7 years ago

I'm really sorry but may be you found a solution? I't really important for my users. Thanks a lot!

And your method above has an other glitch effect )=

Sorry again but can I ask? If table has a method to stop update? I have one table and user can change datasource (with [tableView reloadData]) when table is waiting a new data. In this moment app crash (something like that

Invalid update: invalid number of rows in section 0.

) or insert new (but already wrong) data.

smalldevcloud commented 8 months ago

I'm really sorry but may be you found a solution?

I had the same error.

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (30) must be equal to the number of items contained in that section before the update (20), plus or minus the number of items inserted or deleted from that section (0 inserted, 0 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out).

For me it turned out better to do infinite scroll without any library, with using UICollectionViewDataSourcePrefetching.s better to do infinite scroll without any library, with using UICollectionViewDataSourcePrefetching.