一、创建一个列表,不管代码还是nib拖拉,在nib创建的时候,记得加他的二个代理 (UITableViewDelegate UITableViewDataSource)

代码创建的话,需要关联他的代理,nib创建则不需要关联,他自动会关联。。。代码创建关联的方法为

 LXDataTable = [[UITableView alloc] initWithFrame:CGRectMake(, , , )];

 [LXDataTable setDelegate:self];

 [LXDataTable setDataSource:self];

 [self.view addSubview:DataTable];

 [LXDataTable release];

二、UITableview的每一个代理的Method 使用和 讲解

 //Section总数

 - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{

  return TitleData;

 }

 // Section Titles

 //每个section显示的标题

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

  return @"";

 }

 //指定有多少个分区(Section),默认为1

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

  return ;

 }

 //指定每个分区中有多少行,默认为1

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

 }

 //绘制Cell

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

 static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";

     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:

                              SimpleTableIdentifier];

     if (cell == nil) {  

         cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault

                                        reuseIdentifier: SimpleTableIdentifier] autorelease];

  }

  cell.imageView.image=image;//未选cell时的图片

  cell.imageView.highlightedImage=highlightImage;//选中cell后的图片

  cell.text=//.....

  return cell;

 }

 //行缩进

 -(NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath{

  NSUInteger row = [indexPath row];

  return row;

 }

 //改变行的高度

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

     return ;

 }

 //定位

 [TopicsTable setContentOffset:CGPointMake(, promiseNum *  + Chapter * )];

 //返回当前所选cell

 NSIndexPath *ip = [NSIndexPath indexPathForRow:row inSection:section];

 [TopicsTable selectRowAtIndexPath:ip animated:YES scrollPosition:UITableViewScrollPositionNone];

 [tableView setSeparatorStyle:UITableViewCellSelectionStyleNone];

 //选中Cell响应事件

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

  [tableView deselectRowAtIndexPath:indexPath animated:YES];//选中后的反显颜色即刻消失

 }

 //判断选中的行(阻止选中第一行)

 -(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath

 {

     NSUInteger row = [indexPath row];

     if (row == )

         return nil;

     return indexPath;

 }

 //划动cell是否出现del按钮

 - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {

 }

 //编辑状态

 - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle

 forRowAtIndexPath:(NSIndexPath *)indexPath

 {

 }

 [topicsTable setContentSize:CGSizeMake(,controller.promiseNum * )];

 //右侧添加一个索引表

 - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{

 }

 //返回Section标题内容

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

 }

 //自定义划动时del按钮内容

 - (NSString *)tableView:(UITableView *)tableView

 titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath

 //跳到指的row or section

 [tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow: inSection:] atScrollPosition:UITableViewScrollPositionBottom animated:NO];

三、在UITableViewCell上建立多个 UILable ,来代替cell的加载显示

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

     static NSString *CellIdentifier = @"Cell";   

     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

     if (cell == nil) {

         cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];

   UILabel *Datalabel = [[UILabel alloc] initWithFrame:CGRectMake(, , , )];

   [Datalabel setTag:];

   Datalabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

   [cell.contentView addSubview:Datalabel];

   [Datalabel release];

  } 

  UILabel *Datalabel = (UILabel *)[cell.contentView viewWithTag:];

  [Datalabel setFont:[UIFont boldSystemFontOfSize:]];

  Datalabel.text = [data.DataArray objectAtIndex:indexPath.row];

  cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

     return cell;

 }

 //选中cell时的颜色

 typedef enum {

     UITableViewCellSelectionStyleNone,

     UITableViewCellSelectionStyleBlue,

     UITableViewCellSelectionStyleGray

 } UITableViewCellSelectionStyle 

 //cell右边按钮格式

 typedef enum {

     UITableViewCellAccessoryNone,                   // don't show any accessory view

     UITableViewCellAccessoryDisclosureIndicator,    // regular chevron. doesn't track

     UITableViewCellAccessoryDetailDisclosureButton, // blue button w/ chevron. tracks

     UITableViewCellAccessoryCheckmark               // checkmark. doesn't track

 } UITableViewCellAccessoryType

 //是否加换行线

 typedef enum {

     UITableViewCellSeparatorStyleNone,

     UITableViewCellSeparatorStyleSingleLine

 } UITableViewCellSeparatorStyle//改变换行线颜色

 tableView.separatorColor = [UIColor blueColor];

IOS 中列表的TableView 详解,常用方法整理的更多相关文章

  1. iOS中MVC等设计模式详解

    iOS中MVC等设计模式详解 在iOS编程,利用设计模式可以大大提高你的开发效率,虽然在编写代码之初你需要花费较大时间把各种业务逻辑封装起来.(事实证明这是值得的!) 模型-视图-控制器(MVC)设计 ...

  2. iOS中线程同步基本详解

    为什么使用线程同步技术:多个线程是同时执行的 如果多个线程同时操作一个资源 会造成此资源的数据错乱 线程同步简介 线程同步,多条线程按顺序地访问某个资源 注意:此处的同步不是一起执行的意思 是一个一个 ...

  3. IOS中的NSTimer定时器详解

    /* 在IOS中有多种定时器,这里我对NSTimer定时器做了一个简单的介绍.如果你是小白,你可能会从这篇文章中学习到一些知识,如果你是大牛,请别吝啬你的评论,指出我的不足,你的质疑是对我最大的帮助. ...

  4. iOS中 CoreGraphics快速绘图(详解) 韩俊强的博客

    每日更新关注:http://weibo.com/hanjunqiang  新浪微博 第一步:先科普一下基础知识: Core Graphics是基于C的API,可以用于一切绘图操作 Core Graph ...

  5. iOS中 蓝牙2.0详解/ios蓝牙设备详解 韩俊强的博客

    每日更新关注:http://weibo.com/hanjunqiang  新浪微博 整体布局如下:     程序结构如右图: 每日更新关注:http://weibo.com/hanjunqiang  ...

  6. iOS中UINavigationController控制器使用详解

    一.概述 UINavigationController用来管理视图控制器,在多视图控制器中常用.它以栈的形式管理视图控制器,管理视图控制器个数理论上不受限制(实际受内存限制),push和pop方法来弹 ...

  7. iOS中--NSArray调用方法详解 (李洪强)

    下面的例子以     NSArray *array = [NSArray arrayWithObjects:@"wendy",@"andy",@"to ...

  8. IOS中的网络编程详解

    在移动互联网时代,几乎所有应用都需要用到网络,比如QQ.微博.网易新闻.优酷.百度地图,只有通过网络跟外界进行数据交互.数据更新,应用才能保持新鲜.活力,如果没有了网络,也就缺少了数据变化,无论外观多 ...

  9. IOS中UIActionSheet使用方法详解

    一.初始化方法 - (instancetype)initWithTitle:(NSString *)title delegate:(id<UIActionSheetDelegate>)de ...

随机推荐

  1. Git远程仓库(github

    一.创建远程仓库(github) 首先到https://github.com注册一个账号,创建自己的Git,点击repositories,再点new 名字自定义,比如叫fansik,选择public点 ...

  2. C++知识点

    typedef typedef struct _COMSTAT { DWORD fCtsHold : ; //机构内位域的定义即变量fCtsHold占1个bit空间 DWORD fDsrHold : ...

  3. 在as3中使用protobuf

    在最近参与开发的adobe air项目中,前后端的通信协议从XML.JSON再到protobuf,最后选择protobuf原因,主要是前后端维护protobuf协议就行了,同时还可以利用IDE做一些编 ...

  4. C#序列化与反序列化方式简单总结

    序列化和反序列化 相关类: System.SerializableAttribute特性(或称为属性), System.Runtime.Serialization.ISerializable(自定义序 ...

  5. MongoDB学习笔记九:分片

    分片(sharding)是指将数据拆分,将其分散存在不同的机器上的过程.有事也用分区(partitioning)来表示这个概念.将数据分散到不同的机器上,不需要功能强大的大型计算机既可以存储更多的数据 ...

  6. [课程设计]Scrum 1.1 NABCD模型&产品Backlog

    多鱼点餐系统WEB NABCD模型 & 产品Backlog ● 一.NABCD模型  1) N (Need 需求) 为了解决餐饮企业在同行中的竞争优势,减少顾客到店后的点餐.等餐及结算过程消耗 ...

  7. English—句子

    1. So far so good.   目前为止,一切都好. 2. Be my guest.     请便.别客气. 3. You're the boss.    听你的. 4.I've heard ...

  8. JSBinding+Bridge.NET:Unity游戏热更新方案

    老版本链接如下:http://www.cnblogs.com/answerwinner/p/4469021.html 新用户不要再使用老版本了. 新版本 JSBinding 将抛弃 SharpKit ...

  9. Bridge.NET

    块作用域闭包问题 结果正确:1 容易引入JSB:1 public class Program { static List<Action> createActions() { List< ...

  10. 深入理解CSS中的层叠上下文和层叠顺序(转)

    by zhangxinxu from http://www.zhangxinxu.com 本文地址:http://www.zhangxinxu.com/wordpress/?p=5115 零.世间的道 ...