码迷,mamicode.com
首页 > 其他好文 > 详细

Xcode--UITableView

时间:2014-12-05 10:51:42      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:io   ar   for   on   数据   cti   ad   ef   as   

一、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

Xcode--UITableView

标签:io   ar   for   on   数据   cti   ad   ef   as   

原文地址:http://www.cnblogs.com/ZhangYuGe/p/4146024.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!