Extract flow layout methods into a separate delegate

This commit is contained in:
Levi McCallum 2015-09-22 20:43:18 -07:00 committed by Levi McCallum
parent cefbcef831
commit 2956c0cd8a
3 changed files with 21 additions and 5 deletions

View File

@ -342,18 +342,34 @@
*/ */
- (BOOL)shouldBatchFetchForCollectionView:(ASCollectionView *)collectionView; - (BOOL)shouldBatchFetchForCollectionView:(ASCollectionView *)collectionView;
@end
@protocol ASCollectionViewDelegateFlowLayout <ASCollectionViewDelegate>
@optional
/** /**
* Passthrough support to UICollectionViewDelegateFlowLayout sectionInset behavior. * Passthrough support to UICollectionViewDelegateFlowLayout sectionInset behavior.
* *
* @param collectionView The sender. * @param collectionView The sender.
* @param collectionViewLayout The layout object requesting the information. * @param collectionViewLayout The layout object requesting the information.
* #param section The index number of the section whose insets are needed. * @param section The index number of the section whose insets are needed.
* *
* @discussion The same rules apply as the UICollectionView implementation, but this can also be used without a UICollectionViewFlowLayout. * @discussion The same rules apply as the UICollectionView implementation, but this can also be used without a UICollectionViewFlowLayout.
* https://developer.apple.com/library/ios/documentation/UIKit/Reference/UICollectionViewDelegateFlowLayout_protocol/index.html#//apple_ref/occ/intfm/UICollectionViewDelegateFlowLayout/collectionView:layout:insetForSectionAtIndex: * https://developer.apple.com/library/ios/documentation/UIKit/Reference/UICollectionViewDelegateFlowLayout_protocol/index.html#//apple_ref/occ/intfm/UICollectionViewDelegateFlowLayout/collectionView:layout:insetForSectionAtIndex:
* *
*/ */
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section; - (UIEdgeInsets)collectionView:(ASCollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section;
/**
* Asks the delegate for the size of the header in the specified section.
*/
- (CGSize)collectionView:(ASCollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section;
/**
* Asks the delegate for the size of the footer in the specified section.
*/
- (CGSize)collectionView:(ASCollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section;
@end @end

View File

@ -628,7 +628,7 @@ static BOOL _isInterceptedSelector(SEL sel)
} }
if (_asyncDelegateImplementsInsetSection) { if (_asyncDelegateImplementsInsetSection) {
sectionInset = [_asyncDelegate collectionView:self layout:self.collectionViewLayout insetForSectionAtIndex:indexPath.section]; sectionInset = [(id<ASCollectionViewDelegateFlowLayout>)_asyncDelegate collectionView:self layout:self.collectionViewLayout insetForSectionAtIndex:indexPath.section];
} }
if (ASScrollDirectionContainsHorizontalDirection([self scrollableDirections])) { if (ASScrollDirectionContainsHorizontalDirection([self scrollableDirections])) {

View File

@ -13,7 +13,7 @@
#import <AsyncDisplayKit/AsyncDisplayKit.h> #import <AsyncDisplayKit/AsyncDisplayKit.h>
@interface ViewController () <ASCollectionViewDataSource, ASCollectionViewDelegate> @interface ViewController () <ASCollectionViewDataSource, ASCollectionViewDelegateFlowLayout>
{ {
ASCollectionView *_collectionView; ASCollectionView *_collectionView;
} }
@ -95,7 +95,7 @@
[context completeBatchFetching:YES]; [context completeBatchFetching:YES];
} }
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section { - (UIEdgeInsets)collectionView:(ASCollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
return UIEdgeInsetsMake(20.0, 20.0, 20.0, 20.0); return UIEdgeInsetsMake(20.0, 20.0, 20.0, 20.0);
} }