UITableView的基本使用
- 遵循数据源协议
<UITableViewDataSource>
@interface ViewController () <UITableViewDataSource> - 设置数据源对象
self.tableView.dataSource = self; - 实现数据源方法
-
numberOfSectionsInTableView有多少组数据。
Default is 1 if not implemented, 没有实现此方法,默认为1组。 -
numberOfRowsInSection:(NSInteger)section每组有多少行数据。
section: 当前为哪一组 -
cellForRowAtIndexPath:(NSIndexPath *)indexPath每行显示的内容。(注意: 需返回UITableViewCell)
indexPath包含:
indexPath.section- 哪一组
indexPath.row- 哪一行
设置cell右边的指示样式
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
-

其他方法
titleForHeaderInSection: 返回每组组头的标题
titleForFooterInSection: 返回每组组尾的标题
