总结: UITableViewDelegate
  row:     heightForRow
  header:    heightForHeader
         viewForHeader
         titleForHeader (viewForHeader 相冲突)
  

  title:     heightForTitle
         viewForTitle
         titleForTitle (viewForTitle 相冲突)
 
 总结: UITableViewDatasource
  numberOfRowsInSection      (required)
      cellForRow          (required)

UITableView应用(一)UITableViewDelegate方法总结

 
1.定义每个UITableView中的cell的行高
 

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{

// indexPath.section,根据分组进行更精确的配置

return 90.0;

}

 
2.设置UITableView每个分组的Header的Title
 

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{

return [_arrayType objectAtIndex:section];

}

 
3.设置UITableView分组Header的高
 

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{

return 30.0;

}

 
4.设置UITableView自定义的Header
 

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{

// 自定义的Header

ViewForCellHeader *headerView=[[[ViewForCellHeader alloc] init] autorelease];

headerView.strSectionName=[_arrayType objectAtIndex:section];

return [headerView view];

}

 

注意:2与4是互斥的。

 
同理原理,我们分别也对Footer进行设置。
 
5.设置UITableView每个分组的Footer的Title
 

- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section{

return [_arrayType objectAtIndex:section];

}

 
6.设置UITableView分组Footer的高
 

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{

// indexPath.section,根据分组进行更精确的配置

return 30.0;

}

 
7.设置UITableView自定义的Footer
 

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{

// 自定义的Footer

ViewForCellHeader *headerView=[[[ViewForCellHeader alloc] init] autorelease];

headerView.strSectionName=[_arrayType objectAtIndex:section];

return [headerView view];

}

 
8.设置UITableView每个分组的Footer的Title
 

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{

return [_arrayType objectAtIndex:section];

}

UITableView应用(二)UITableViewDataSource 方法总结

NSMutableArray *_arrayType;// 分组

 

1.返回分组数

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

return [_arrayType count];

}

2.根据分组,返回每个分组的行数
 

- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{

NSString *curType=[_arrayType objectAtIndex:section];

return [[_dictData objectForKey:curType] count];

}

 
3.根据分组,返回每个cell
 

- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath
*)indexPath{

NSUInteger section = [indexPath section];

NSUInteger row = [indexPath row];

NSString *key=[_arrayType objectAtIndex:section];

NSMutableArray *arrValues=[_dictData objectForKey:key];

static NSString *CellIdentifier = @"WTVChannelCell";

// 自定义cell

WTVChannelCell *cell = (WTVChannelCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil){

cell = [[[WTVChannelCell alloc] initWithStyle:UITableViewCellSelectionStyleGray
reuseIdentifier:CellIdentifier]
autorelease];

NSArray *array =
[[NSBundle mainBundle] loadNibNamed:@"WTVChannelCell" owner:nil
options:nil];

cell =
[array objectAtIndex:0];

}

cell.dictChannelData=[arrValues objectAtIndex:row];

[cell refreshCellData];

return cell;

}

UITableView 委托方法总结的更多相关文章

  1. (转载)IOS中UIScrollView的属性和委托方法

    http://www.jizhishusheng.com/?p=453   ---- 以下内容来自 UIScrollView 类负责所有基于 UIKit 的滚动操作一.创建 1. CGRect bou ...

  2. UITableView表格视图、UITableView代理方法及应用

    一.基本知识点 UITableView表格视图,是一个可以滚动的界面(理解为垂直滚动的UIScrollView),可展示多行数据,没有行数的限制,只能有一列. 使用UITableView: 1.展示信 ...

  3. 事件、委托、委托方法的总结(使用EventHandler<>)

    在C#中,定义事件.委托.委托方法可以使用类库内的EventHandler泛型委托来定义事件.并根据该泛型委托定义实现方法: 同样您也可以自定义委托 来定义事件以及 根据自定义的委托来定义实现事件的方 ...

  4. .NET自带泛型委托方法Func、Action和Predicate

    Func.Action和Predicate是.NET自带的3个泛型委托方法,三个方法的区别其实并不大,要强行给混着用也是可以的,但是我们是有追求的人,把道理讲清楚总是好的. 一.Func是有返回值的方 ...

  5. 匿名委托(方法) 以 ThreadStart 为例

    Hello Tec.   匿名委托(方法) 以 ThreadStart 为例 REF:http://baike.baidu.com/view/2761370.htm?fr=aladdin   不使用匿 ...

  6. IOS UITableview代理方法总结

    tableview的datasource代理 @required的两个数据源方法 1.返回每个 session 中 cell 的个数 - (NSInteger)tableView:(UITableVi ...

  7. 两种局部刷新UITableView的方法的使用条件

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ //1.取消选 ...

  8. 【转】iOS UITableView的方法解析

    原文网址:http://www.cnblogs.com/wfwenchao/articles/3718742.html - (void)viewDidLoad { [super viewDidLoad ...

  9. jQuery事件委托方法 bind live delegate on

    1.bind    jquery 1.3之前 定义和用法:主要用于给选择到的元素上绑定特定事件类型的监听函数 语法:  bind(type,[data],function(e)); 特点: a.适合页 ...

随机推荐

  1. 用html5+js实现掌机游戏赛车demo

    最近无聊,用html5+js做了一个以前玩过的掌机赛车游戏,顺便学习一下画布的api以及巩固一下js基础. 游戏界面,没做什么美化. 游戏规则:游戏界面分为三列,黑色方块随机落下,红色方块可以在三列自 ...

  2. 【Visual Studio】在VS2012中使用VSXtra

    最近工作中需要把之前为VS 2010写的扩展迁移到VS 2012上.在将工程版本改为VS2012之后,代码没有修改,直接编译通过,也可以安装到VS2012上. 不过,在实际使用的时候,却报错,提示“T ...

  3. Timer的性能优势

    假如有这样一个场景,1个100万用户同时在线的系统,假设有一个Session管理器来管理它们的存亡,每个用户的Session有效时间假设5分钟,通常一个最简单的做法是在一个Session管理器中启动一 ...

  4. JS实现Ajax,Josn数据的序列化和反序列化---例: 省市区联动(包含get,post)

    服务器端相应JOSN数据   用到序列化和反序列化----命名空间using System.Web.Script.Serialization; public void ProcessRequest(H ...

  5. 使用quartz 定时任务

    Quartz 是一个开源的作业调度框架,它完全由 Java 写成,并设计用于 J2SE 和 J2EE 应用中.它提供了巨大的灵活性而不牺牲简单性.你能够用它来为执行一个作业而创建简单的或复杂的调度. ...

  6. Bsoj 1322 第K小数

    第K小数 Description 现在已有N个整数,你有以下三种操作: 1 A:表示加入一个值为A的整数: 2 B:表示删除其中值为B的整数: 3 K:表示输出这些整数中第K小的数: Input 第一 ...

  7. C#获取局域网中的所有正在使用的IP地址

    方法不是很好. using System; using System.Collections.Generic; using System.Linq; using System.Text; using ...

  8. Opencv加载和显示图片

    #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <ios ...

  9. MySQL里面的子查询实例

    一,子选择基本用法 1,子选择的定义 子迭择允许把一个查询嵌套在另一个查询当中.比如说:一个考试记分项目把考试事件分为考试(T)和测验(Q)两种情形.下面这个查询就能只找出学生们的考试成绩 selec ...

  10. --hdu 1800 Flying to the Mars(贪心)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1800 Ac code: #include<stdio.h> #include<std ...