Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable UICollectionView animation on reloadData

For some reason, my UICollectionView animates the transition inside the visible cell when calling reloadData.

From what I understood it shouldn't do that, and that's what I am trying to do.

Why would the collection view animate on reload data? And how could I stop it?

I will be eventually using [UIView setAnimationsEnabled:YES/NO], but I would be hoping to fix it without too much extra code.

like image 945
Alex Avatar asked Feb 10 '14 14:02

Alex


People also ask

What is the use of uicollectionviewdelegate?

var delegate: UICollectionViewDelegate? Reloads all of the data for the collection view. Call this method sparingly when you need to reload all of the items in the collection view. This causes the collection view to discard any currently visible items (including placeholders) and recreate items based on the current state of the data source object.

What is insert and remove in uicollectionview?

INSERTING AND REMOVING ITEMS UICollectionView provides several methods for explicitly animating position and content updates to cells in the collection, rather than simply calling reloadData and having it instantly change.

How does the collection view work with animation blocks?

For efficiency, the collection view only displays those cells and supplementary views that are visible. If the collection data shrinks as a result of the reload, the collection view adjusts its scrolling offsets accordingly. You shouldn’t call this method in the middle of animation blocks where items are being inserted or deleted.

How many scrollable content can be displayed in uicollectionview?

UICollectionView is a subclass of UIScrollView and, as such, it can support virtually infinite scrollable content.


1 Answers

[UIView performWithoutAnimation:^{
            [self.collectionView reloadSections:[NSIndexSet indexSetWithIndex:0]];
        }];
like image 83
fennghu Avatar answered Nov 15 '22 01:11

fennghu