STDTableView 是基于 UITableView 的封装,实现了一套 High Level 的 API,提供了更简洁的构建及使用方法。
- 初始化
// 快速构建(使用本方法构建的tableView内部已经初始化了DataSoure)
UITableView *tableView = [UITableView tableViewWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - kNavigationBarMaxY) style:UITableViewStylePlain];
tableView.delegate = self;
tableView.rowHeight = 55;
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
tableView.tableFooterView = [[UIView alloc]init];
// viewController传递,可在cell中使用
//tableView.viewController = self;
// 注册Cell, nib构建的Cell使用以下方法:
[tableView registerCellNibClass:[STDExampleListCell class]];
// 注册Cell, 代码构建的Cell使用以下方法:
//[tableView registerCellClass:[STDExampleListCell class]];
// 注:如果是使用系统方法或者nib构建tableView,则需要调用以下方法创建内部数据源:
//[tableView creatDataSource];
// 新建section并添加到tableview数据源中
STDTableViewSection *sectionData = [[STDTableViewSection alloc] initWithCellClass:[STDExampleListCell class]];
[tableView addSection:sectionData];
...
- 添加数据并更新
NSArray *itemList = @[[STDExampleListItem itemWithTitle:@"1. 头部点击缩放" subTitle:nil object:[STDExampleHeaderViewController class]],
[STDExampleListItem itemWithTitle:@"2. Cell事件响应" subTitle:nil object:[STDExampleCellEventViewController class]],
[STDExampleListItem itemWithTitle:@"3. 混合Cell" subTitle:nil object:[STDExampleMixCellsViewController class]]];
//添加数据到指定section中
[self.tableView addItems:itemList atSection:0];
//更新数据
[self.tableView insertRows:itemList.count atEmptySection:0 withRowAnimation:UITableViewRowAnimationFade];
...
-
完成
-
更多使用方法请查看demo, 持续更新中...