diff --git a/CHTCollectionViewWaterfallLayout.m b/CHTCollectionViewWaterfallLayout.m index e1ce651..194659f 100644 --- a/CHTCollectionViewWaterfallLayout.m +++ b/CHTCollectionViewWaterfallLayout.m @@ -193,13 +193,6 @@ - (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) { @@ -212,6 +205,13 @@ - (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];