Latest 1.0.5
Homepage https://github.com/silence0201/UIScrollViewWrap
License MIT
Platforms ios 7.0, requires ARC
Dependencies UITableView+FDTemplateLayoutCell
Authors

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.

Latest podspec

{
    "name": "SIScrollViewWrap",
    "version": "1.0.5",
    "summary": "ScrollViewWrap With Model",
    "description": "A ScrollViewWrap With Model",
    "homepage": "https://github.com/silence0201/UIScrollViewWrap",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Silence": "[email protected]"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/silence0201/UIScrollViewWrap.git",
        "tag": "1.0.5"
    },
    "requires_arc": true,
    "dependencies": {
        "UITableView+FDTemplateLayoutCell": [
            "~> 1.4"
        ]
    },
    "subspecs": [
        {
            "name": "UITableView",
            "source_files": "UIScrollViewWrap/{UITableView,Common}/**/*.{h,m}",
            "public_header_files": "UIScrollViewWrap/{UITableView,Common}/**/*.{h}"
        },
        {
            "name": "UICollectionView",
            "source_files": "UIScrollViewWrap/{UICollection,Common}/**/*.{h,m}",
            "public_header_files": "UIScrollViewWrap/{UICollection,Common}/**/*.{h}"
        }
    ]
}

Pin It on Pinterest

Share This