From 5df9c02e96fe8da8c20884141220980128b42091 Mon Sep 17 00:00:00 2001 From: Dylan Ginsburg Date: Fri, 27 Mar 2015 18:22:13 -0400 Subject: [PATCH] Remove cached layout attribute objects when collection view has 0 sections --- CHTCollectionViewWaterfallLayout.m | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/CHTCollectionViewWaterfallLayout.m b/CHTCollectionViewWaterfallLayout.m index 194659f..e1ce651 100644 --- a/CHTCollectionViewWaterfallLayout.m +++ b/CHTCollectionViewWaterfallLayout.m @@ -193,6 +193,13 @@ - (id)initWithCoder:(NSCoder *)aDecoder { #pragma mark - Methods to Override - (void)prepareLayout { [super prepareLayout]; + + [self.headersAttribute removeAllObjects]; + [self.footersAttribute removeAllObjects]; + [self.unionRects removeAllObjects]; + [self.columnHeights removeAllObjects]; + [self.allItemAttributes removeAllObjects]; + [self.sectionItemAttributes removeAllObjects]; NSInteger numberOfSections = [self.collectionView numberOfSections]; if (numberOfSections == 0) { @@ -205,13 +212,6 @@ - (void)prepareLayout { // Initialize variables NSInteger idx = 0; - [self.headersAttribute removeAllObjects]; - [self.footersAttribute removeAllObjects]; - [self.unionRects removeAllObjects]; - [self.columnHeights removeAllObjects]; - [self.allItemAttributes removeAllObjects]; - [self.sectionItemAttributes removeAllObjects]; - for (NSInteger section = 0; section < numberOfSections; section++) { NSInteger columnCount = [self columnCountForSection:section]; NSMutableArray *sectionColumnHeights = [NSMutableArray arrayWithCapacity:columnCount];