Handle initial sizing delegate implementation in flow layout inspector

This commit is contained in:
Levi McCallum
2015-10-06 09:26:23 -07:00
parent 34f3065825
commit 8efca60bac
3 changed files with 42 additions and 14 deletions

View File

@@ -228,13 +228,8 @@ static BOOL _isInterceptedSelector(SEL sel)
// Register the default layout inspector delegate for flow layouts, custom layouts
// will need to roll their own ASCollectionViewLayoutInspecting implementation.
if ([layout asdk_isFlowLayout]) {
_flowLayoutInspector = [[ASCollectionViewFlowLayoutInspector alloc] init];
_flowLayoutInspector.layout = (UICollectionViewFlowLayout *)layout;
_flowLayoutInspector.collectionView = self;
_layoutDelegate = _flowLayoutInspector;
}
_layoutDelegate = [self flowLayoutInspector];
_registeredSupplementaryKinds = [NSMutableArray array];
self.backgroundColor = [UIColor whiteColor];
@@ -252,6 +247,21 @@ static BOOL _isInterceptedSelector(SEL sel)
super.dataSource = nil;
}
/**
* A layout inspector implementation specific for the sizing behavior of UICollectionViewFlowLayouts
*
* @discussion Will return nil if the current layout is not a flow layout
*/
- (ASCollectionViewFlowLayoutInspector *)flowLayoutInspector
{
if (_flowLayoutInspector == nil) {
UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)self.collectionViewLayout;
_flowLayoutInspector = [[ASCollectionViewFlowLayoutInspector alloc] initWithCollectionView:self
flowLayout:layout];
}
return _flowLayoutInspector;
}
#pragma mark -
#pragma mark Overrides.
@@ -326,6 +336,8 @@ static BOOL _isInterceptedSelector(SEL sel)
super.delegate = (id<UICollectionViewDelegate>)_proxyDelegate;
_asyncDelegateImplementsInsetSection = ([_asyncDelegate respondsToSelector:@selector(collectionView:layout:insetForSectionAtIndex:)] ? 1 : 0);
}
_flowLayoutInspector.collectionView = self;
}
- (void)setTuningParameters:(ASRangeTuningParameters)tuningParameters forRangeType:(ASLayoutRangeType)rangeType