一、UITableView

1、数据展示的条件
1>UITableView的所有数据都是由数据源(dataSource)提供的,所以要像在UITableView展示数据,必须设置UITableView的dataSource数据源对象
2>要想用UITableView的dataSource对象,必须遵守UITableViewDataSource协议,实现相应的数据源方法
3>当UITableView想要展示数据的时候,就会给数据源发送消息(调用数据源方法),UITableView会提供方法返回值决定展示怎样的数据

2、数据展示的过程
1>先调用数据源的
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
得知一共有多少组

2>然后调用数据源的
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
得知第section组一共有多少行

3>然后调用数据源的
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
得知第indexPath.section组 第indexPath.row行显示怎样的cell(显示什么内容)

3、常见数据源方法

1>一共有多少组
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

2>第section组一共有多少行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

3>第indexPath.section组 第indexPath.row行显示怎样的cell(显示什么内容)
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

4>第section组显示怎样的头部标题
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section

5>第section组显示怎样的尾部标题
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section

6>添加右侧索引条
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView

posted on 2014-12-05 10:11  墓厄  阅读(149)  评论(0编辑  收藏  举报