UITableView是一个用于显示列表的视图,可以作为子视图镶嵌在主视图上,可以滑动,选取各种参数

定义:

@interface ViewController : UIViewController<UITableViewDataSource,UITableViewDelegate>{

@property (nonatomic, retain) NSArray *dataList;

@property (nonatomic, retain) UITableView *myTableView;

    UITableView *tableView = [[UITableViewalloc] initWithFrame:FRAME_TABLEVIEWstyle:UITableViewStylePlain];

注意:这里的两个属性 dataList和myTableView并不要求实现,只需要在头文件定义就可以了

Delegate必须要有,因为必须要实现它的接口

使用:

    //init tableView

    NSArray *list = [NSArray arrayWithObjects:@"模糊",@"素描",@"怀旧", nil];

    self.dataList = list;

    // 设置tableView的数据源

    tableView.dataSource = self;

    // 设置tableView的委托

    tableView.delegate = self;

    // 设置tableView的背景图

//    tableView.backgroundView = [[UIImageView alloc] init];

    self.myTableView = tableView;

    self.myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;

    [self.view addSubview:self.myTableView];

常用的属性设置:

    //设置转置,使table view倒过来

);

    //取消滑动出现删除

    tableView.showsVerticalScrollIndicator = NO;

接口的实现:

 

//set cells

//定义每个列表项的属性

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

{

    static NSString *CellWithIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellWithIdentifier];

    if (cell == nil) {

        cell = [[UITableViewCellalloc] initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:CellWithIdentifier];

    }

    cell.imageView.image = [UIImageimageNamed:@"example.png"];

    return cell;

}

 

//set number of sections

//定义块的个数

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

{

    ;

}

 

//行首缩进

//定义首行缩进的宽度

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

{

    ;

}

 

//row height

//定义每一行的高度

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

{

    ;

}

 

 

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

{

//    if ([indexPath row] % 2 == 0) {

//        cell.backgroundColor = [UIColor blueColor];

//    } else {

//        cell.backgroundColor = [UIColor greenColor];

//    }

}

 

 

//select rows callback

//选择某行以后的动作方法

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

{

    switch ([indexPath row]) {

        :

            testFilter = [[GPUImageFastBlurFilteralloc] init];

            break;

        :

            testFilter = [[GPUImageSketchFilteralloc] init];

            break;

        :

            testFilter = [[GPUImageSepiaFilteralloc] init];

            break;

        default:

            break;

    } 

}

 

 

// delete

//选择删除以后的方法

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath

{

    NSLog(@"执行删除操作");

}

 

//设置没有分界线

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{

    returnUITableViewCellEditingStyleNone;

}

 

 

//number of rows

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

{

    returnself.dataList.count;

}

 

简单tableView的使用的更多相关文章

  1. Masonry学习分享

    不完整目录 •UIScrollView 应用Masonry的正确用法 •tableHeaderView使用Masonry •同向文字显示优先级 1.基础篇 1.1基础使用 1.1.1运行效果 1.1. ...

  2. iOS面试考察点

    )自我介绍.项目经历.专业知识.自由提问 (2)准备简历.投发简历.笔试(电话面试.).面试.复试.终面试.试用.转正.发展.跳槽(加薪升职) 1闲聊 a)自我介绍:自我认识能力 b)评价上一家公司: ...

  3. IOS xib在tableview上的简单应用(通过xib自定义cell)

    UITableView是一种常用的UI控件,在实际开发中,由于原生api的局限,自定义UITableViewCell十分重要,自定义cell可以通过代码,也可以通过xib. 这篇随笔介绍的是通过xib ...

  4. 简单天气应用开发——自定义TableView

    顺利解析JSON数据后,天气数据已经可以随意提取了,现在要做的就是建立一个简单的UI. 实况信息较为简单,几个Lable就可以解决.主要是七天天气预报有点麻烦,那是一个由七个字典构成的数组,需要提取出 ...

  5. IOS中TableView的使用(1) -创建一个简单的tableView

    创建一个简单的tableView: #import <UIKit/UIKit.h> /*tableView 一定要遵守这两个协议: UITableViewDataSource,UITabl ...

  6. 【转】ios tableView那些事(一)创建一个简单的tableView

    工作也有半年多了!几乎每个项目中的会用到tableview这个神奇而好用的控件,在学习和工作中都会看别人的博客!对我有很大的帮助,就如同站在巨人的肩膀上的感觉吧 哈哈!于是决定重新开始写博客,希望能帮 ...

  7. 简单的TableView

    背景知识 每个表都是UITableView的实例,表中的每一行都是UITableViewCell的实例. TableView的种类 Grouped table Plain table without ...

  8. tableView简单的动画效果

    tableView 中一些动画效果通常都是实现willDisplayCell的方法来展示出一些动画的效果 (1).带有3D效果的小型动态展示 -(void)tableView:(UITableView ...

  9. 关于tableView的简单实例

    关于tableCell选中颜色 //无色 cell.selectionStyle = UITableViewCellSelectionStyleNone; //蓝色 cell.selectionSty ...

随机推荐

  1. Ubuntu12.04中安装ns-allinone-2.34

    1.首先安装ns2所需的组件.库之类: $sudo apt-get update $sudo apt-get install build-essential $ tcl8.-dev tk8. tk8. ...

  2. OC相关-02:oc和c的基本差异

    前言: 面向过程和面向对象. 简单的说,面向过程就是分析出解决问题所需要的步骤,然后用函数把这些步骤一步一步实现,使用的时候一个一个依次调用. 面向对象是把构成问题事务分解成各个对象,建立对象的目的不 ...

  3. [C#][转]与MySql连接访问

    using System;using System.Configuration;using MySql.Data.MySqlClient;/// <summary>/// TestDate ...

  4. linux命令sed学习笔记

    sed其实就是两个主要的知识点,那就是“怎么选择”和“怎么操作”!

  5. 转 C#开发微信门户及应用(1)--开始使用微信接口

    微信应用如火如荼,很多公司都希望搭上信息快车,这个是一个商机,也是一个技术的方向,因此,有空研究下.学习下微信的相关开发,也就成为日常计划的重要事情之一了.本系列文章希望从一个循序渐进的角度上,全面介 ...

  6. Asp.net服务器控件在IE10下的不兼容问题

    Asp.net服务器控件在IE10下的不兼容问题 时间:2013-05-16 09:07点击: 89 次 [大 中 小] 相信很多使用IE10的童鞋们已经发现了这个问题,以下是本人在IE10标准模式下 ...

  7. 怎样让老浏览器兼容html5新标签

    CSS样式设置默认样式: <style> article, aside, canvas, details, figcaption, figure, footer, header, hgro ...

  8. 我的第一篇博客:requestAnimationFrame学习笔记

    通常,我们在浏览器中写动画会用到哪些技术呢? flash 可以实现一些非常复杂的动画,但随着HTML5的成熟,个人感觉flash终究会成为明日黄花. css3 当前大部分现代浏览器已经对css3支持的 ...

  9. ie9以上浏览器input文本框/密码框后面的小叉子/小眼睛问题

    找了很久不知什么属性控制的这个东西,经过群友的指点重要找到.

  10. PHP实战开发教程

    对于PHP初学者来说,一上手就学习庞大的PHP语法无疑很打击自信心.其实即便是很熟练的程序员,也未必对所有的语法非常熟悉.通常熟练的程序员比普通的程序员的优势在于对基本语法的理解非常透彻,而且常用的一 ...