一个静态UITabelView的解决方案----CTStaticTableView

来源:互联网 发布:excel不规则数据分列 编辑:程序博客网 时间:2024/05/29 13:26

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代码。

https://github.com/chentoo/CTStaticTableView

0 0
原创粉丝点击