Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Manger UITableView DataSource Cells

License

NotificationsYou must be signed in to change notification settings

josercc/ZHTableViewGroup

Repository files navigation


Swift 版本请移步这里

ZHTableViewGroupUITableViewUICollectionView 而生

演示

简单的列表

image-20200928175235608

ZHTableViewDataSource *dataSource = [[ZHTableViewDataSourcealloc]initWithTableView:self.tableView];[dataSourceclearData];[dataSourceaddGroupWithCompletionHandle:^(ZHTableViewGroup * _Nonnull group) {    [groupaddCellWithCompletionHandle:^(ZHTableViewCell *tableViewCell) {        tableViewCell.anyClass = [UITableViewCellclass];        tableViewCell.identifier =@"UITableViewCell";NSArray<NSString *> *titles = @[@"刷新高度",@"刷新Cell",@"刷新数据",@"显示和隐藏"];        tableViewCell.cellNumber = titles.count;        [tableViewCellsetConfigCompletionHandle:^(UITableViewCell *cell,NSIndexPath *indexPath) {            cell.textLabel.text = titles[indexPath.row];        }];    }];}];[dataSourcereloadTableViewData];

动态刷新高度

image-20200928175932428

[self.tableViewDataSourceclearData];[self.tableViewDataSourceaddGroupWithCompletionHandle:^(ZHTableViewGroup *group) {    [groupaddCellWithCompletionHandle:^(ZHTableViewCell<ReloadHeightCell1 *> *cell) {        self->_weakCell = cell;        cell.anyClass = [ReloadHeightCell1class];        cell.identifier =@"ReloadHeightCell1";        [cellsetConfigCompletionHandle:^(ReloadHeightCell1 *cell1,NSIndexPath *indexPath) {            cell1.textLabel.text =@"ReloadHeightCell1";        }];    }];}];[self.tableViewDataSourceaddGroupWithCompletionHandle:^(ZHTableViewGroup *group) {    [groupaddCellWithCompletionHandle:^(ZHTableViewCell<ReloadHeightCell2 *> *cell) {        cell.anyClass = [ReloadHeightCell2class];        cell.identifier =@"ReloadHeightCell2";        cell.cellNumber =2;        [cellsetConfigCompletionHandle:^(ReloadHeightCell2 *cell1,NSIndexPath *indexPath) {            cell1.textLabel.text =@"ReloadHeightCell2";        }];    }];}];[self.tableViewDataSourcereloadTableViewData];

identifier更新自动高度

[self.tableViewDataSourcereloadCellAutomaticHeightWithIdentifier:@"ReloadHeightCell1"]

identifier更新固定250高度

[self.tableViewDataSourcereloadCellFixedHeight:250identifier:@"ReloadHeightCell1"]

Class更新自动高度

[self.tableViewDataSourcereloadCellAutomaticHeightWithClass:NSClassFromString(@"ReloadHeightCell1")]

Class更新固定260高度

[self.tableViewDataSourcereloadCellFixedHeight:260className:NSClassFromString(@"ReloadHeightCell1")]

指定ZHTableViewCell更新自动高度

[self.tableViewDataSourcereloadCellAutomaticHeightWithTableViewCell:self.tableViewDataSource.groups[0].cells[0]]

指定ZHTableViewCell更新固定270高度

[self.tableViewDataSourcereloadCellFixedHeight:270tableViewCell:self.tableViewDataSource.groups[0].cells[0]]

指定索引更新自动高度

[self.tableViewDataSourcereloadCellAutomicHeightWithGroupIndex:1cellIndex:0]

指定索引更新固定280高度

[self.tableViewDataSourcereloadCellFixedHeight:280groupIndex:1cellIndex:0]

刷新值

image-20200928180955425

[self.tableViewDataSourceclearData];[self.tableViewDataSourceaddGroupWithCompletionHandle:^(ZHTableViewGroup *group) {    [groupaddCellWithCompletionHandle:^(ZHTableViewCell *cell) {        cell.anyClass = [UITableViewCellclass];        cell.identifier =@"UITableViewCell";        [cellsetConfigCompletionHandle:^(UITableViewCell *cell,NSIndexPath *indexPath) {            cell.textLabel.text = [@(random() %99 +1)stringValue];        }];    }];}];[self.tableViewDataSourcereloadTableViewData];

通过Identifier刷新

[self.tableViewDataSourcereloadCellWithIdentifier:@"UITableViewCell"]

通过Class刷新

[self.tableViewDataSourcereloadCellWithClassName:[UITableViewCellclass]]

通过指定UITableViewCell更新

[self.tableViewDataSourcereloadCellWithTableViewCell:self.tableViewDataSource.groups[0].cells[0]]

通过索引更新

[self.tableViewDataSourcereloadCellWithGroupIndex:0cellIndex:0]

刷新个数

image-20200928181349639

_randoms = [NSMutableArrayarrayWithArray:@[@"random"]];[self.tableViewDataSourceclearData];[self.tableViewDataSourceaddGroupWithCompletionHandle:^(ZHTableViewGroup *group) {    [groupaddCellWithCompletionHandle:^(ZHTableViewCell *cell) {        cell.anyClass = [UITableViewCellclass];        cell.identifier =@"UITableViewCell";        cell.cellNumber = _randoms.count;        [cellsetConfigCompletionHandle:^(UITableViewCell *cell,NSIndexPath *indexPath) {            cell.textLabel.text = _randoms[indexPath.row];        }];    }];}];[self.tableViewDataSourcereloadTableViewData];

identifier刷新个数

[self.tableViewDataSourcereloadCellWithDataCount:_randoms.countidentifier:@"UITableViewCell"]

Class刷新个数

[self.tableViewDataSourcereloadCellWithDataCount:_randoms.countclassName:[UITableViewCellclass]]

UITableViewCell刷新个数

[self.tableViewDataSource reloadCellWithDataCount:_randoms.count tableViewCell:self.tableViewDataSource.groups[0].cells[0]]

索引刷新个数

[self.tableViewDataSourcereloadCellWithDataCount:_randoms.countgroupIndex:0cellIndex:0]

显示和隐藏

image-20200928190127141

[self.tableViewDataSourceclearData];[self.tableViewDataSourceaddGroupWithCompletionHandle:^(ZHTableViewGroup *group) {    [groupaddCellWithCompletionHandle:^(ZHTableViewCell *cell) {        cell.anyClass = [UITableViewCellclass];        cell.identifier =@"UITableViewCell";        cell.cellNumber =10;        [cellsetConfigCompletionHandle:^(UITableViewCell *cell,NSIndexPath *indexPath) {            cell.textLabel.text = [@(indexPath.row +1)stringValue];        }];        [cellsetHiddenBlock:^BOOL(NSIndexPath *indexPath) {return _hidden && indexPath.row >=5 && indexPath.row <=8;        }];    }];}];[self.tableViewDataSourcereloadTableViewData];

隐藏Cell

[self.tableViewDataSourcereloadAllHiddenCell]

怎么安装

Cocoapods

pod'ZHTableViewGroup'

Carthage

github"josercc/ZHTableViewGroup"

Swift Package Manager

.package(url:"https://github.com/josercc/ZHTableViewGroup.git", from:"3.0.0")

About

Manger UITableView DataSource Cells

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2026 Movatter.jp