总结: 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. 开源搜索引擎Iveely 0.7.0发布,不一样,那就让他不一样!

    2012年08月05日,Iveely Search Engine 0.1.0发布,今天,怀着对于未来的追求,终于,0.7.0如期和大家见面了,7个版本,历时2年4个月,感谢大家的支持,感谢我不离不弃的 ...

  2. Github上Python开发者应该关心的Repo

    carbaugh/lice lice : Generate license files for your projects 一个用来为你的项目生成许可证的工具.这下可方便了,不用手工的去修改了! co ...

  3. Mtk Ft6306 touch 驱动 .

    1.1.    MTK Touch 驱动的组成Mtk  Touch  driver 驱动包括:Mtk platform 虚拟平台设备驱动.Module touch IC 驱动.Input subsys ...

  4. Visual Studio命令窗口

    命令”窗口用于直接在 Visual Studio 集成开发环境 (IDE) 中执行命令或别名.可以执行菜单命令和不在任何菜单上显示的命令.若要显示“命令”窗口,请从“视图”菜单中选择“其他窗口”,再选 ...

  5. 第四十五课:MVC,MVP,MVVM的区别

    前端架构从MVC到MVP,再到MVVM,它们都有不同的应用场景.但MVVM已经被证实为界面开发最好的方案了. MVP 是从经典的模式MVC演变而来,它们的基本思想有相通的地方:Controller/P ...

  6. HTML5——地图应用

    我们就拿百度地图举例吧: 废话少说,直接上Demo 简要截图如下:' 简要代码如下: <!DOCTYPE html> <html> <head> <title ...

  7. 【BZOJ 3188】【Coci 2011】Upit Splay模板题

    转啊转终于转出来了,然而我的模板跟陈竞潇学长的模板一模一样,还是太弱啊,第一次用指针. #include<cstdio> #include<cstring> #include& ...

  8. 在 Visual Studio 2013 中创建 ASP.NET Web 项目(0):专题导航 [持续更新中]

    写在前面的话 随着 Visual Studio 2013 的正式推出,ASP.NET 和 Visual Studio Web 开发工具 也发布了各自的最新版本. 新版本在构建 One ASP.NET ...

  9. PLSQL导入Excel表中数据

     PL/SQL 和SQL Sever导入excel数据的原理类似,就是找到一个导入excel数据的功能项,按照步骤走就是了.下面是一个些细节过程,希望对像我这样的菜鸟有帮助.  www.2cto.co ...

  10. PostConstruct

    Spring AOP注解通过@Autowired,@Resource,@Qualifier,@PostConstruct,@PreDestroy注入属性的配置文件详解 1.6. @PostConstr ...