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];