CTStaticTableView
这是一个用代码封装静态TableView的方式。
你可以用xib初始化CTStaticTableView,也可以用代码:
self.tableView = [[CTStaticTableView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
[self.view addSubview:self.tableView];
然后可以合成你的static table view cell
需要两个参数:一个是TableViewCell对象,一个是他的高度。
CTStaticTableViewCell *fristStaticCell = [CTStaticTableViewCell staticTableViewCellWithCell:[DemoTableViewFristCell fristCell] height:50];
CTStaticTableViewCell *secendStaticCell = [CTStaticTableViewCell staticTableViewCellWithCell:[DemoTableViewSecendCell secendCell] height:80];
拼起来吧
[self.tableView showStaticCells:@[fristStaticCell, secendStaticCell]];
//或者
[self.tableView showStaticCells:@[fristStaticCell, secendStaticCell] withDidSelectRowDelegate:self];
//或者
[self.tableView showStaticCells:@[fristStaticCell, secendStaticCell] withDidSelectRowBlock:^(NSIndexPath *indexPath) {
NSLog(@"taptaptap");
}];
没了,请看demo代码。
本文介绍如何使用代码封装静态TableView,包括初始化方法、创建静态TableViewCell并设置高度,以及展示静态cells的方法。通过示例代码,展示了如何将预制的TableViewCell组合成静态TableView,并提供了选择行的回调函数。

被折叠的 条评论
为什么被折叠?



