From b52b08930d60d878e1e7844e21934a51af83006b Mon Sep 17 00:00:00 2001 From: Darrarski Date: Sun, 11 May 2014 22:53:13 +0200 Subject: [PATCH] Layout - extracted method stickyColumnOrRowHeadersInAnySection --- .../DRCollectionViewTableLayout.m | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/DRCollectionViewTableLayout/DRCollectionViewTableLayout.m b/DRCollectionViewTableLayout/DRCollectionViewTableLayout.m index 0754696..0676f11 100644 --- a/DRCollectionViewTableLayout/DRCollectionViewTableLayout.m +++ b/DRCollectionViewTableLayout/DRCollectionViewTableLayout.m @@ -62,6 +62,18 @@ - (BOOL)stickyRowHeadersInSection:(NSUInteger)section } } +- (BOOL)stickyColumnOrRowHeadersInAnySection +{ + NSUInteger sectionsCount = [self.collectionView.dataSource numberOfSectionsInCollectionView:self.collectionView]; + for (NSUInteger sectionIdx = 0; sectionIdx < sectionsCount; sectionIdx++) { + if ([self stickyColumnHeadersInSection:sectionIdx] || [self stickyRowHeadersInSection:sectionIdx]) { + return YES; + } + } + + return NO; +} + - (CGFloat)widthForRowHeaderInSection:(NSUInteger)section { if ([self.delegate respondsToSelector:@selector(collectionView:tableLayout:widthForRowHeaderInSection:)]) { @@ -150,19 +162,8 @@ - (UICollectionViewLayoutInvalidationContext *)invalidationContextForBoundsChang { DRCollectionViewTableLayoutInvalidationContext *context = (DRCollectionViewTableLayoutInvalidationContext *)[super invalidationContextForBoundsChange:newBounds]; - NSUInteger sectionsCount = [self.collectionView.dataSource numberOfSectionsInCollectionView:self.collectionView]; - BOOL stickyColumnHeaders = NO; - BOOL stickyRowHeaders = NO; - for (NSUInteger sectionIdx = 0; sectionIdx < sectionsCount; sectionIdx++) { - stickyColumnHeaders = [self stickyColumnHeadersInSection:sectionIdx]; - stickyRowHeaders = [self stickyRowHeadersInSection:sectionIdx]; - if (stickyColumnHeaders || stickyRowHeaders) { - break; - } - } - context.keepCellsLayoutAttributes = YES; - context.keepSupplementaryViewsLayoutAttributes = !(stickyColumnHeaders || stickyRowHeaders); + context.keepSupplementaryViewsLayoutAttributes = ![self stickyColumnOrRowHeadersInAnySection]; return context; }