-、建立 UITableView

 DataTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 420)];
 [DataTable setDelegate:self];
 [DataTable setDataSource:self];
 [self.view addSubview:DataTable];
 [DataTable 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 4;
}
 
//指定每个分区中有多少行,默认为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 40;
}
 
//定位
[TopicsTable setContentOffset:CGPointMake(0, promiseNum * 44 + Chapter * 20)];
 
//返回当前所选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 == 0)
        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(0,controller.promiseNum * 44)];
//右侧添加一个索引表
- (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:0 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:NO];
三、在UITableViewCell上建立UILable多行显示
- (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(10, 0, 320, 44)];
  [Datalabel setTag:100];
  Datalabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
  [cell.contentView addSubview:Datalabel];
  [Datalabel release];
 } 
 UILabel *Datalabel = (UILabel *)[cell.contentView viewWithTag:100];
 [Datalabel setFont:[UIFont boldSystemFontOfSize:18]];
 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学习--TableView详细解释

    -.建立 UITableView DataTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 420)]; [DataTa ...

  2. iOS开发tableView去掉顶部上部空表区域

    tableview中的第一个cell 里上部 有空白区域,大概64像素 在viewDidLoad中加入如下代码 self.automaticallyAdjustsScrollViewInsets = ...

  3. [IOS 开发] TableView、多个TableViewCell、自定义Cell、Cell上画画(故事板+代码方式)

    第一步: //UserTableViewCell.h这里定义第一种Cell #import <UIKit/UIKit.h> @interface UserTableViewCell : U ...

  4. iOS开发tableview二级联动的细节实现中注意的细节总结

    首先说网络慢带来的数据显示问题 可以通过判断请求参数是否一致来刷新tableview. SJBCategaryModel * categaryModel = self.categarys[Catega ...

  5. iOS开发 tableView点击下拉扩展 + 内嵌collectionView上传图片效果

    ---恢复内容开始--- //需要的效果 1.设置window的根视图控制器为一个UITableViewController #import "AppDelegate.h"#imp ...

  6. 玩转iOS开发 - Runloop 具体解释

    Runloop 具体解释

  7. IOS开发Block详细用法

    Block简介:       ios4.0系统已开始支持block,在编程过程中,blocks被Obj-C看成是对象,它封装了一段代码,这段代码可以在任何时候执行.Blocks可以作为函数参数或者函数 ...

  8. iOS开发,UITableView相关问题

    第一条:UITableViewCell 内容的设置 //文本放到最后 NSIndexPath *indexPath = [NSIndexPath indexPathForRow:_dataArr.co ...

  9. iOS开发:代码通用性以及其规范 第二篇(猜想iOS中实现TableView内部设计思路(附代码),以类似的思想实现一个通用的进度条)

    在iOS开发中,经常是要用到UITableView的,我曾经思考过这样一个问题,为什么任何种类的model放到TableView和所需的cell里面,都可以正常显示?而我自己写的很多view却只是能放 ...

随机推荐

  1. IPointCollection转IPolyline

    IPointCollection转线IPolyline: IPolyline pl = new PolylineClass(); IPointCollection ptc = pl as IPoint ...

  2. 最全 Adobe 系列产品 CS6版本 序列号/注册码

    最全 Adobe 系列产品 CS6版本 序列号/注册码: 1.Adobe Photoshop CS6 Extended 序列号/注册码 2.Adobe After Effects CS6 序列号/注册 ...

  3. Git快速上手 : Tortoise工具使用

    利用工具快速上手Git 别跟我说什么用命令操作Git,多高大上呀,请不要在这里跟我装逼,就如同,有个小妞在床上眉眼诱惑地,你却TM还要先看个片儿来热热身.... TortoiseGit  名字看着眼熟 ...

  4. Jquery实现简单的分页

    转,Jquery实现简单的翻页功能 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " ...

  5. html5 的<audio> 音频 audio的“坑”

    <audio>标签是html5的一个非常有意义的特性.告别的flash的时代.它的属性有: autoplay:音频就绪后马上播放 controls:出现该属性,向用户显示播放的控件. lo ...

  6. 手写一个自己的简单MVC框架myPHP

    myPHP框架 采用的是MVC 思想,应用纯面向对象及项目单一入口,实现的一个自定义的框架.(自己兴趣的练习) 一.项目单一入口 入口文件 myphp\index.php前台 一个网站所有的请求都请求 ...

  7. php入门引言

    php开发者要具备的一些要求: [1]html常用标签的基础知识 [2]html+css布局的基础知识 [3]了解php开发环境 [4]了解php标签和扩展名 1.php标签是撒??? <?ph ...

  8. phpcms v9 自定义伪静态的分页函数

    因为.这个页面还没做好..等做好了..再给大家演示...... 调用方法:$page_attr=pages_open($num[0]['cun'],$get_page,$max_page,'http: ...

  9. SQL Server— 存在检测、建库、 建表、约束、外键、级联删除

    /******************************************************************************** *主题: SQL Server- 存 ...

  10. python 判断 windows 隐藏文件/系统文件

    linux 下隐藏文件是以句号 “.” 开头的文件,根据文件名即可判断是否为隐藏文件. win 下是以文件隐藏属性确定的,所以,只能通过微软的 API 获取隐藏属性来判断是否为隐藏文件. 1. win ...