TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Sep 2017 |
Maintained by Dokay Dou.
DJCollectionViewVM is a lightweight ViewModel implementation for UICollectionView.
Build and run the DJComponentCollectionViewVM.xcodeproj
in Xcode.
- (void)testNormal
{
DJCollectionViewVMCellRegister(self.collectionVM, DJCollectionViewTitleCellRow, DJCollectionViewTitleCell);
[self.collectionVM removeAllSections];
DJCollectionViewVMSection *contentSection = [DJCollectionViewVMSection sectionWithHeaderHeight:10];
contentSection.minimumLineSpacing = 10.0f;
contentSection.minimumInteritemSpacing = 10.0f;
[self.collectionVM addSection:contentSection];
for (NSInteger i = 0; i < 100; i ++) {
DJCollectionViewTitleCellRow *row = [DJCollectionViewTitleCellRow new];
row.itemSize = CGSizeMake(100, 100);
row.backgroundColor = [UIColor redColor];
row.title = [NSString stringWithFormat:@"%@",@(i)];
[row setSelectionHandler:^(DJCollectionViewVMRow *rowVM) {
NSLog(@"tap %@",rowVM.indexPath);
}];
[contentSection addRow:row];
}
[self.collectionView reloadData];
}
Key Classes | |
---|---|
DJCollectionViewVM | The ViewModel for UICollectionView, which has implemented UICollectionViewDelegate , UICollectionViewDataSource and UICollectionViewDelegateFlowLayout. It has multiple DJCollectionViewVMSection sections. |
DJCollectionViewVMSection | The ViewModel for sections in DJCollectionViewVM, each section has multiple DJCollectionViewVMRow rows. |
DJCollectionViewVMRow | The ViewModel for rows in section,it is the root class of all DJCollectionViewVM row hierarchies. You should subclass DJCollectionViewVMRow to obtain cell characteristics specific to your application's needs. Through DJCollectionViewVMRow, rows inherit a basic interface that communicates with DJCollectionViewVM and DJCollectionViewVMSection. |
DJCollectionViewVMCell | The View for DJCollectionViewVMRow(ViewModel),it defines the attributes and behavior of the cells that appear in UICollectionView objects. You should subclass DJCollectionViewVMCell to obtain cell characteristics and behavior specific to your application's needs. By default, it is being mapped with DJCollectionViewVMRow. |
DJCollectionViewVMReusable | The ViewModel for supplementary view in section header and footer,it is the root class of all DJCollectionViewVM supplementary view hierarchies. You should subclass DJCollectionViewVMReusable to obtain supplementary view characteristics specific to your application's needs. Through DJCollectionViewVMReusable, supplementary views inherit a basic interface that communicates with DJCollectionViewVM and DJCollectionViewVMSection. |
DJCollectionViewVMReusableView | The View for DJCollectionViewVMReusable(ViewModel),it defines the attributes and behavior of the supplementary views that appear in UICollectionView objects. You should subclass DJCollectionViewVMReusableView to obtain supplementary view characteristics and behavior specific to your application's needs. By default, it is being mapped with DJCollectionViewVMReusable. |
##UITableView
ViewModel for UITableView: DJTableViewVM
Dokay Dou
DJCollectionViewVM is available under the MIT license.