CocoaPods trunk is moving to be read-only. Read more on the blog, there are 14 months to go.
| TestsTested | ✗ |
| LangLanguage | Obj-CObjective C |
| License | MIT |
| ReleasedLast Release | Apr 2017 |
Maintained by Silence0201.
基于Model数据对UITableView和UICollectionView进行简单封装
下载项目,导入UIScrollViewWrap目录导入项目中.
Common: 一个公用的关联对象的方法
UITableView: UITableView封装代码
UICollection: UICollection封装代码
如果需要UITableView的封装,只需导入Common和UITableView文件夹到项目中
如果需要UICollection的封装,只需导入Common和UICollection文件夹到项目中
pod 'SIScrollViewWrap','~>1.0'
导入头文件
#import "UITableViewWrap.h"
#import "UICollectionWrap.h"构建数据源
NSMutableArray *array = [NSMutableArray array] ;
for (NSInteger i = 0 ; i < 10 ; i ++){
NSString *str = [NSString stringWithFormat:@"%ld",i] ;
[titleIndex addObject:str] ;
NSMutableDictionary *dic = [NSMutableDictionary dictionary] ;
NSString *titleHeader = [NSString stringWithFormat:@"第%ld组的头",i] ;
NSString *titleFooder = [NSString stringWithFormat:@"第%ld组的尾",i] ;
[dic setObject:titleHeader forKey:kGroupHeaderTitle] ;
[dic setObject:titleFooder forKey:kGroupFooderTitle] ;
NSMutableArray *models = [NSMutableArray array] ;
for (NSInteger j = 0 ; j<10;j++){
NSMutableDictionary *d = [NSMutableDictionary dictionary] ;
[d setObject:[NSString stringWithFormat:@"%ld",j] forKey:kCellTitle] ;
[d setObject:[NSString stringWithFormat:@"%ld",i] forKey:kCellDetail] ;
[d setObject:@(UITableViewCellAccessoryDisclosureIndicator)forKey:kCellAccessoryType] ;
[d setObject:^(NSIndexPath *indexPath){ NSLog(@"%ld--%ld",indexPath.section,indexPath.row); }
forKey:kCellSelected] ;
[models addObject:d] ;
}
[dic setObject:models forKey:kGroupModels] ;
[array addObject:dic] ;
}赋值数据源
self.tableView.models = array ;如果使用代理,不要使用系统的,需要使用下面的代替
@property (nonatomic,weak) id<SITableViewDelegate> sDelegate ;
@property (nonatomic,weak) id<SITableViewDataSource> sDataSource ;自定集成了UITableView+FDTemplateLayoutCell实现了自动计算高度,只需要设置下面进行开启
/// 是否支持Cell自动计算高度,默认不支持
@property (nonatomic,assign) BOOL autoLayout ;更多使用方法查看Demo
UIScrollViewWrap is available under the MIT license. See the LICENSE file for more info.