To run the example project, clone the repo, and run pod install
from the Example directory first.
CJCollectionViewAdapter is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'CJCollectionViewAdapter'
- Init
- (CJCollectionViewAdapter *)adapter {
if (_adapter == nil) {
CJCollectionViewAdapter *adapter = [[CJCollectionViewAdapter alloc] init];
_adapter = adapter;
}
return _adapter;
}
- (UICollectionView *)collectionView {
if (_collectionView == nil) {
UICollectionView *aView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:self.adapter.wrappedCollectionViewLayout];
[self.adapter attachCollectionView:aView];
aView.alwaysBounceVertical = YES;
aView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.1];
if (@available(iOS 11.0, *)) {
aView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
if (@available(iOS 13.0, *)) {
aView.automaticallyAdjustsScrollIndicatorInsets = NO;
}
aView.mj_header = [MJRefreshStateHeader headerWithRefreshingTarget:self refreshingAction:@selector(viewControllerShouldReloadData)];
aView.mj_footer = [MJRefreshAutoStateFooter footerWithRefreshingTarget:self refreshingAction:@selector(viewControllerShouldLoadMoreData)];
_collectionView = aView;
}
return _collectionView;
}
- Setup Sections
- (void)viewControllerReloadData {
[self.adapter updateSections:@[ [TestSectionDataA new], [TestSectionDataB new], [TestSectionDataC new] ... ]];
}
- Implement DataSource And Delegate Methods If Necessary In SectionData
cj1024, [email protected]
CJCollectionViewAdapter is available under the MIT license. See the LICENSE file for more info.