{"id":20536415,"url":"https://github.com/josercc/zhtableviewgroup","last_synced_at":"2025-04-14T07:21:48.304Z","repository":{"id":56930563,"uuid":"68171474","full_name":"josercc/ZHTableViewGroup","owner":"josercc","description":"Manger UITableView DataSource Cells","archived":false,"fork":false,"pushed_at":"2020-09-28T11:46:57.000Z","size":731,"stargazers_count":19,"open_issues_count":0,"forks_count":12,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-27T21:03:28.157Z","etag":null,"topics":["uitableview","uitableviewdatasource"],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/josercc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-14T03:50:31.000Z","updated_at":"2021-08-31T06:26:57.000Z","dependencies_parsed_at":"2022-08-21T05:50:15.528Z","dependency_job_id":null,"html_url":"https://github.com/josercc/ZHTableViewGroup","commit_stats":null,"previous_names":["15038777234/zhtableviewgroup"],"tags_count":48,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josercc%2FZHTableViewGroup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josercc%2FZHTableViewGroup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josercc%2FZHTableViewGroup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josercc%2FZHTableViewGroup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/josercc","download_url":"https://codeload.github.com/josercc/ZHTableViewGroup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248837190,"owners_count":21169382,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["uitableview","uitableviewdatasource"],"created_at":"2024-11-16T00:36:36.381Z","updated_at":"2025-04-14T07:21:48.275Z","avatar_url":"https://github.com/josercc.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\nfilename:images\n---\n\n\n\n## Swift 版本请移步[这里](https://github.com/josercc/SwiftTableViewGroup)\n\n`ZHTableViewGroup`为 `UITableView`和 `UICollectionView` 而生\n\n## 演示\n\n### 简单的列表\n\n![image-20200928175235608](https://gitee.com/joser_zhang/upic/raw/master/uPic/image-20200928175235608.png)\n\n```objc\nZHTableViewDataSource *dataSource = [[ZHTableViewDataSource alloc] initWithTableView:self.tableView];\n[dataSource clearData];\n[dataSource addGroupWithCompletionHandle:^(ZHTableViewGroup * _Nonnull group) {\n    [group addCellWithCompletionHandle:^(ZHTableViewCell *tableViewCell) {\n        tableViewCell.anyClass = [UITableViewCell  class];\n        tableViewCell.identifier = @\"UITableViewCell\";\n        NSArray\u003cNSString *\u003e *titles = @[@\"刷新高度\",@\"刷新Cell\",@\"刷新数据\",@\"显示和隐藏\"];\n        tableViewCell.cellNumber = titles.count;\n        [tableViewCell setConfigCompletionHandle:^(UITableViewCell *cell, NSIndexPath *indexPath) {\n            cell.textLabel.text = titles[indexPath.row];\n        }];\n    }];\n}];\n[dataSource reloadTableViewData];\n```\n\n### 动态刷新高度\n\n![image-20200928175932428](https://gitee.com/joser_zhang/upic/raw/master/uPic/image-20200928175932428.png)\n\n```objc\n[self.tableViewDataSource clearData];\n[self.tableViewDataSource addGroupWithCompletionHandle:^(ZHTableViewGroup *group) {\n    [group addCellWithCompletionHandle:^(ZHTableViewCell\u003cReloadHeightCell1 *\u003e *cell) {\n        self-\u003e_weakCell = cell;\n        cell.anyClass = [ReloadHeightCell1 class];\n        cell.identifier = @\"ReloadHeightCell1\";\n        [cell setConfigCompletionHandle:^(ReloadHeightCell1 *cell1, NSIndexPath *indexPath) {\n            cell1.textLabel.text = @\"ReloadHeightCell1\";\n        }];\n    }];\n}];\n[self.tableViewDataSource addGroupWithCompletionHandle:^(ZHTableViewGroup *group) {\n    [group addCellWithCompletionHandle:^(ZHTableViewCell\u003cReloadHeightCell2 *\u003e *cell) {\n        cell.anyClass = [ReloadHeightCell2 class];\n        cell.identifier = @\"ReloadHeightCell2\";\n        cell.cellNumber = 2;\n        [cell setConfigCompletionHandle:^(ReloadHeightCell2 *cell1, NSIndexPath *indexPath) {\n            cell1.textLabel.text = @\"ReloadHeightCell2\";\n        }];\n    }];\n}];\n[self.tableViewDataSource reloadTableViewData];\n```\n\n#### identifier更新自动高度\n\n```objc\n[self.tableViewDataSource reloadCellAutomaticHeightWithIdentifier:@\"ReloadHeightCell1\"]\n```\n\n#### identifier更新固定250高度\n\n```objc\n[self.tableViewDataSource reloadCellFixedHeight:250 identifier:@\"ReloadHeightCell1\"]\n```\n\n#### Class更新自动高度\n\n```objc\n[self.tableViewDataSource reloadCellAutomaticHeightWithClass:NSClassFromString(@\"ReloadHeightCell1\")]\n```\n\n#### Class更新固定260高度\n\n```objc\n[self.tableViewDataSource reloadCellFixedHeight:260 className:NSClassFromString(@\"ReloadHeightCell1\")]\n```\n\n#### 指定ZHTableViewCell更新自动高度\n\n```objc\n[self.tableViewDataSource reloadCellAutomaticHeightWithTableViewCell:self.tableViewDataSource.groups[0].cells[0]]\n```\n\n#### 指定ZHTableViewCell更新固定270高度\n\n```objc\n[self.tableViewDataSource reloadCellFixedHeight:270 tableViewCell:self.tableViewDataSource.groups[0].cells[0]]\n```\n\n#### 指定索引更新自动高度\n\n```objc\n[self.tableViewDataSource reloadCellAutomicHeightWithGroupIndex:1 cellIndex:0]\n```\n\n#### 指定索引更新固定280高度\n\n```objc\n[self.tableViewDataSource reloadCellFixedHeight:280 groupIndex:1 cellIndex:0]\n```\n\n### 刷新值\n\n![image-20200928180955425](https://gitee.com/joser_zhang/upic/raw/master/uPic/image-20200928180955425.png)\n\n```objc\n[self.tableViewDataSource clearData];\n[self.tableViewDataSource addGroupWithCompletionHandle:^(ZHTableViewGroup *group) {\n    [group addCellWithCompletionHandle:^(ZHTableViewCell *cell) {\n        cell.anyClass = [UITableViewCell class];\n        cell.identifier = @\"UITableViewCell\";\n        [cell setConfigCompletionHandle:^(UITableViewCell *cell, NSIndexPath *indexPath) {\n            cell.textLabel.text = [@(random() % 99 + 1) stringValue];\n        }];\n    }];\n}];\n[self.tableViewDataSource reloadTableViewData];\n```\n\n#### 通过Identifier刷新\n\n```objc\n[self.tableViewDataSource reloadCellWithIdentifier:@\"UITableViewCell\"]\n```\n\n#### 通过Class刷新\n\n```objc\n[self.tableViewDataSource reloadCellWithClassName:[UITableViewCell class]]\n```\n\n#### 通过指定UITableViewCell更新\n\n```objc\n[self.tableViewDataSource reloadCellWithTableViewCell:self.tableViewDataSource.groups[0].cells[0]]\n```\n\n#### 通过索引更新\n\n```objc\n[self.tableViewDataSource reloadCellWithGroupIndex:0 cellIndex:0]\n```\n\n### 刷新个数\n\n![image-20200928181349639](https://gitee.com/joser_zhang/upic/raw/master/uPic/image-20200928181349639.png)\n\n```objc\n_randoms = [NSMutableArray arrayWithArray:@[@\"random\"]];\n[self.tableViewDataSource clearData];\n[self.tableViewDataSource addGroupWithCompletionHandle:^(ZHTableViewGroup *group) {\n    [group addCellWithCompletionHandle:^(ZHTableViewCell *cell) {\n        cell.anyClass = [UITableViewCell class];\n        cell.identifier = @\"UITableViewCell\";\n        cell.cellNumber = _randoms.count;\n        [cell setConfigCompletionHandle:^(UITableViewCell *cell, NSIndexPath *indexPath) {\n            cell.textLabel.text = _randoms[indexPath.row];\n        }];\n    }];\n}];\n[self.tableViewDataSource reloadTableViewData];\n```\n\n#### identifier刷新个数\n\n```objc\n[self.tableViewDataSource reloadCellWithDataCount:_randoms.count identifier:@\"UITableViewCell\"]\n```\n\n#### Class刷新个数\n\n```objc\n[self.tableViewDataSource reloadCellWithDataCount:_randoms.count className:[UITableViewCell class]]\n```\n\n#### UITableViewCell刷新个数\n\n```swift\n[self.tableViewDataSource reloadCellWithDataCount:_randoms.count tableViewCell:self.tableViewDataSource.groups[0].cells[0]]\n```\n\n#### 索引刷新个数\n\n```objc\n[self.tableViewDataSource reloadCellWithDataCount:_randoms.count groupIndex:0 cellIndex:0]\n```\n\n### 显示和隐藏\n\n![image-20200928190127141](https://gitee.com/joser_zhang/upic/raw/master/uPic/image-20200928190127141.png)\n\n```objc\n[self.tableViewDataSource clearData];\n[self.tableViewDataSource addGroupWithCompletionHandle:^(ZHTableViewGroup *group) {\n    [group addCellWithCompletionHandle:^(ZHTableViewCell *cell) {\n        cell.anyClass = [UITableViewCell class];\n        cell.identifier = @\"UITableViewCell\";\n        cell.cellNumber = 10;\n        [cell setConfigCompletionHandle:^(UITableViewCell *cell, NSIndexPath *indexPath) {\n            cell.textLabel.text = [@(indexPath.row + 1) stringValue];\n        }];\n        [cell setHiddenBlock:^BOOL(NSIndexPath *indexPath) {\n            return _hidden \u0026\u0026 indexPath.row \u003e= 5 \u0026\u0026 indexPath.row \u003c= 8;\n        }];\n    }];\n}];\n[self.tableViewDataSource reloadTableViewData];\n```\n\n#### 隐藏Cell\n\n```objc\n[self.tableViewDataSource reloadAllHiddenCell]\n```\n\n## 怎么安装\n\n### Cocoapods\n\n```ruby\npod 'ZHTableViewGroup'\n```\n\n### Carthage\n\n```ruby\ngithub \"josercc/ZHTableViewGroup\"\n```\n\n### Swift Package Manager\n\n```swift\n.package(url: \"https://github.com/josercc/ZHTableViewGroup.git\", from: \"3.0.0\")\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosercc%2Fzhtableviewgroup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjosercc%2Fzhtableviewgroup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosercc%2Fzhtableviewgroup/lists"}