UITableView的简单使用
2014-04-21 15:02
274 查看
UITableView在ios开发中,很重要,它的实现只要有两个部分组成。第一:数据源方法 第二:代理方法。
下面我们就详细的介绍一些数据源和代理方法的使用:
1.数据源方法->常用的5个数据源方法
在初始化后的tableView中,有两个数据源方法必须实现。
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;//返回表格中有多少行
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;//返回每一行显示的内容
剩下的方法都是可选的
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
// 返回在表格中将要显示有多少组
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;
// 返回头部标题
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section; //返回尾部标题
2.代理方法 ->常用的
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath; //选中这一行就会调用该方法
tableview的代理方法太多了,其它的暂时还每研究,晚些会更新的。
下面我们就详细的介绍一些数据源和代理方法的使用:
1.数据源方法->常用的5个数据源方法
在初始化后的tableView中,有两个数据源方法必须实现。
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;//返回表格中有多少行
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;//返回每一行显示的内容
剩下的方法都是可选的
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
// 返回在表格中将要显示有多少组
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;
// 返回头部标题
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section; //返回尾部标题
2.代理方法 ->常用的
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath; //选中这一行就会调用该方法
tableview的代理方法太多了,其它的暂时还每研究,晚些会更新的。
相关文章推荐
- UITableView 基本使用方法总结
- UITableView一些易混属性和方法
- UITableView的详细讲解
- (转)UITableViewController重要配置方法和Delegate
- UITableView详细用法,UITableView指南,UITableView详细教程
- UITableView 实现异步加载图片之改进
- UITableView中设置section内行数以及配置cell的方法
- 如何结合CoreData给UITableView的section填充数据
- iOS之UITableView之样板代码
- [iOS7]IOS7中UITableView的变化
- iOS开发经验-2014-1-17
- UITableView(一)
- UITableView(一)
- tablefooterview的显示问题 解决方案
- IOS UITableView 移动自定义cell
- UITableView 隐藏空白cell的分割线
- 为UITableView增加左右滑动事件
- 局部刷新UITableView
- UITableView使用简介
- UITableView Class 参考 (1)<Creating Table View Cells>