Manger UITableView DataSource Cells
Objective-C Shell Ruby
Latest commit b6070ac Mar 20, 2017 15038777234 更新了说明文档
Permalink
Failed to load latest commit information.
Example 更新了说明文档 Mar 20, 2017
ZHTableViewGroup 修复了代码编译错误 Mar 20, 2017
.DS_Store init Mar 18, 2017
.gitignore init Mar 18, 2017
.travis.yml init Mar 18, 2017
LICENSE init Mar 18, 2017
QQ20160914-0.png Add files via upload Sep 14, 2016
QQ20160914-1.png Add files via upload Sep 14, 2016
README.md 更新了说明文档 Mar 20, 2017
ZHTableViewGroupObjc.podspec 更新了说明文档 Mar 20, 2017
_Pods.xcodeproj init Mar 18, 2017

README.md

Swift 版本请移步这里

ZHTableViewGroup为 UITableView 而生

怎么安装

pod 'ZHTableViewGroupObjc'

怎么使用

  1. 初始化 ZHTableViewDataSource

    @property (nonatomic, strong) ZHTableViewDataSource *dataSource;
    self.dataSource = [[ZHTableViewDataSource alloc] initWithTableView:self.tableView];
  2. 初始化 ZHTableViewGroup

    [self.dataSource addGroupWithCompletionHandle:^(ZHTableViewGroup *group) {
    }
  3. 初始化 ZHTableViewCell

    [group addCellWithCompletionHandle:^(ZHTableViewCell *cell) {  
    }
  4. 配置 ZHTableViewCell

      cell.anyClass = [UITableViewCell class];
                cell.cellNumber = self.cellTexts.count;
                cell.height = 44;
                cell.identifier = @"UITableViewCellIdentifier";
                [cell setConfigCompletionHandle:^(UITableViewCell *cell, NSIndexPath *indexPath) {
                    NSString *string = self.cellTexts[indexPath.row];
                    cell.textLabel.text = string;
                    if ([self.selectTitles containsObject:string]) {
                        cell.accessoryType = UITableViewCellAccessoryCheckmark;
                    } else {
                        cell.accessoryType = UITableViewCellAccessoryNone;
                    }
                }];
                [cell setDidSelectRowCompletionHandle:^(UITableViewCell *cell, NSIndexPath *indexPath) {
                    NSString *string = self.cellTexts[indexPath.row];
                    if ([self.selectTitles containsObject:string]) {
                        [self.selectTitles removeObject:string];
                    } else {
                        [self.selectTitles addObject:string];
                    }
                    [self.tableView reloadData];
                }];
    
  5. 配置 UITableView的代理

    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
        return [ZHTableViewDataSource heightForRowAtDataSource:self.dataSource indexPath:indexPath customHeightCompletionHandle:nil];
    }
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
        return [ZHTableViewDataSource numberOfRowsInSectionWithDataSource:self.dataSource section:section];
    }
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        return [ZHTableViewDataSource cellForRowAtWithDataSource:self.dataSource indexPath:indexPath];
    }
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        [tableView deselectRowAtIndexPath:indexPath animated:YES];
        [ZHTableViewDataSource didSelectRowAtWithDataSource:self.dataSource indexPath:indexPath];
    }
    

6 清除配置

[self.dataSource clearData];