总结: 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. node的实践(项目一)

    学习一门语言,我们先要学习他的基本的语法,基本的数据类型,基本的数组操作,字符串的操作,然后就是语言的特性,实现共享和降低耦合的方式,然后开始比较高级的学习(所有语言都是一样的),比如说通信方法,tc ...

  2. JAVA中的NIO(一)

    1.IO与NIO IO就是普通的IO,或者说原生的IO.特点:阻塞式.内部无缓冲,面向流. NIO就是NEW IO,比原生的IO要高效.特点:非阻塞.内部有缓存,面向缓冲. 要实现高效的IO操作,尤其 ...

  3. 第十六章:脚本化HTTP

    写在本章内容前: 第十五章:事件处理 涉及到到较多的文字篇幅,介于个人精力问题,暂不更新.主要包含的内容有事件类型.注册事件处理程序.事件处理程序的调用.文档加载事件.鼠标事件.鼠标滚轮事件.拖放事件 ...

  4. ORA-12737: Instant Client Light: unsupported server character set CHS16GBK/ZHS16GBK解决方案

    二.Navicat for Oracle的配置 1.启动该工具,出现如下的开始界面,单击“连接”选项,进行连接数据库,如图所示: 6.在“新建连接”对话框中,输入任意的连接名,选择默认的连接类型,输入 ...

  5. logic标签用法

    logic  <logic:iterate> <% Dog dog1=new Dog(); dog1.setAge(2); dog1.setName("xiaoming& ...

  6. [转载]VS2012编译C语言scanf函数error的解决方法

    在VS 2012 中编译 C 语言项目,如果使用了 scanf 函数,编译时便会提示如下错误: error C4996: 'scanf': This function or variable may ...

  7. JavaScript事件冒泡简介及应用

    一.什么是事件冒泡 在一个对象上触发某类事件(比如单击onclick事件),如果此对象定义了此事件的处理程序,那么此事件就会调用这个处理程序,如果没有定义此事 件处理程序或者事件返回true,那么这个 ...

  8. MVC4学习笔记(一)

    1.查询 1)Controllers /// <summary> /// 数据上下文对象 /// </summary> OumindBlogEntities db = new ...

  9. [转]DIV+CSS和TABLE的区别

    现在全国大大小小的网站都在搞一场技术“革命”,就是所谓“网站重构”说简单点就是DIV+CSS进行网站制作.用DIV+CSS代替传统的Table制作框架和美化页面.百度搜索优化 在重构之前,肯定要了解为 ...

  10. Unix/Linux 命令技巧

    锁定一个文件夹 为了我的数据隐私,我想要锁定我文件服务器下的/downloads文件夹.因此我运行了: chmod 0000 /downloads root用户仍旧可以访问,而ls和cd命令则不工作. ...