SIScrollViewWrap 1.0.5

SIScrollViewWrap 1.0.5

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Apr 2017

Maintained by Silence0201.



  • By
  • Silence

UIScrollViewWrap

基于Model数据对UITableViewUICollectionView进行简单封装

安装

1. 手动安装

下载项目,导入UIScrollViewWrap目录导入项目中.

Common: 一个公用的关联对象的方法
UITableView: UITableView封装代码
UICollection: UICollection封装代码

如果需要UITableView的封装,只需导入CommonUITableView文件夹到项目中
如果需要UICollection的封装,只需导入CommonUICollection文件夹到项目中

2. Pod安装

pod 'SIScrollViewWrap','~>1.0'

用法

  1. 导入头文件

    #import "UITableViewWrap.h"
    #import "UICollectionWrap.h"
  2. 构建数据源

    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] ;
    }
  3. 赋值数据源

    self.tableView.models = array ;
  4. 如果使用代理,不要使用系统的,需要使用下面的代替

    @property (nonatomic,weak) id<SITableViewDelegate> sDelegate ;
    @property (nonatomic,weak) id<SITableViewDataSource> sDataSource ;
  5. 自定集成了UITableView+FDTemplateLayoutCell实现了自动计算高度,只需要设置下面进行开启

    /// 是否支持Cell自动计算高度,默认不支持
    @property (nonatomic,assign) BOOL autoLayout ;
  6. 更多使用方法查看Demo

UIScrollViewWrap

UIScrollViewWrap is available under the MIT license. See the LICENSE file for more info.