Merge pull request #1571 from maicki/FixASPagerNodeDataSourceSourceInconsistency

[ASPagerNode] Fix ASPagerNode data source and delegate inconsistencies
This commit is contained in:
appleguy 2016-05-10 13:44:39 -07:00
commit a1d2f8ccc6
4 changed files with 19 additions and 13 deletions

View File

@ -342,7 +342,7 @@ NS_ASSUME_NONNULL_BEGIN
* This is a node-based UICollectionViewDataSource.
*/
#define ASCollectionViewDataSource ASCollectionDataSource
@protocol ASCollectionDataSource <ASCommonCollectionViewDataSource, NSObject>
@protocol ASCollectionDataSource <ASCommonCollectionViewDataSource>
@optional

View File

@ -11,7 +11,8 @@
@class ASPagerNode;
@class ASPagerFlowLayout;
@protocol ASPagerNodeDataSource <NSObject>
#define ASPagerNodeDataSource ASPagerDataSource
@protocol ASPagerDataSource <NSObject>
/**
* This method replaces -collectionView:numberOfItemsInSection:
@ -65,25 +66,30 @@
@end
@protocol ASPagerDelegate <ASCollectionDelegate>
@end
@interface ASPagerNode : ASCollectionNode
// Configures a default horizontal, paging flow layout with 0 inter-item spacing.
/// Configures a default horizontal, paging flow layout with 0 inter-item spacing.
- (instancetype)init;
// Initializer with custom-configured flow layout properties.
/// Initializer with custom-configured flow layout properties.
- (instancetype)initWithCollectionViewLayout:(ASPagerFlowLayout *)flowLayout;
// Data Source is required, and uses a different protocol from ASCollectionNode.
- (void)setDataSource:(id <ASPagerNodeDataSource>)dataSource;
- (id <ASPagerNodeDataSource>)dataSource;
/// Data Source is required, and uses a different protocol from ASCollectionNode.
- (void)setDataSource:(id <ASPagerDataSource>)dataSource;
- (id <ASPagerDataSource>)dataSource;
// Delegate is optional, and uses the same protocol as ASCollectionNode.
// This includes UIScrollViewDelegate as well as most methods from UICollectionViewDelegate, like willDisplay...
@property (nonatomic, weak) id <ASCollectionDelegate> delegate;
@property (nonatomic, weak) id <ASPagerDelegate> delegate;
// The underlying ASCollectionView object.
/// The underlying ASCollectionView object.
@property (nonatomic, readonly) ASCollectionView *view;
/// Scroll the contents of the receiver to ensure that the page is visible.
- (void)scrollToPageAtIndex:(NSInteger)index animated:(BOOL)animated;
@end

View File

@ -16,7 +16,7 @@
{
ASPagerFlowLayout *_flowLayout;
ASPagerNodeProxy *_proxy;
__weak id <ASPagerNodeDataSource> _pagerDataSource;
__weak id <ASPagerDataSource> _pagerDataSource;
BOOL _pagerDataSourceImplementsNodeBlockAtIndex;
BOOL _pagerDataSourceImplementsConstrainedSizeForNode;
}
@ -111,12 +111,12 @@
#pragma mark - Data Source Proxy
- (id <ASPagerNodeDataSource>)dataSource
- (id <ASPagerDataSource>)dataSource
{
return _pagerDataSource;
}
- (void)setDataSource:(id <ASPagerNodeDataSource>)pagerDataSource
- (void)setDataSource:(id <ASPagerDataSource>)pagerDataSource
{
if (pagerDataSource != _pagerDataSource) {
_pagerDataSource = pagerDataSource;

View File

@ -77,7 +77,7 @@
- (BOOL)interceptsSelector:(SEL)selector
{
return (
// handled by ASPagerNodeDataSource node<->cell machinery
// handled by ASPagerDataSource node<->cell machinery
selector == @selector(collectionView:nodeForItemAtIndexPath:) ||
selector == @selector(collectionView:nodeBlockForItemAtIndexPath:) ||
selector == @selector(collectionView:numberOfItemsInSection:) ||