- (void)viewDidLoad {

[super viewDidLoad];

self.LabelArray=[[NSMutableArray alloc]initWithObjects:@"个人资料",@"我的收藏",@"我的消息",@"我的房源",@"我的足迹",@"意见反馈",@"关于心家", nil];

self.PicArray=[[NSMutableArray alloc]initWithObjects:@"c11",@"c12",@"c13",@"c14",@"c15",@"c16",@"c17",nil];

// Do any additional setup after loading the view, typically from a nib.

}

//显示行数

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

//    return self.PicArray.count;

switch (section) {

case 0:

return 1;

break;

case 1:

return 4;

break;

default:

return 1;

break;

}

}

//section的个数

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

return 3;

}

//重用机制,重用cell

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

TTTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"cellTest" forIndexPath:indexPath];

switch (indexPath.section) {

case 0:

cell.ImageViewT.image=[UIImage imageNamed:self.PicArray[0]];

cell.LabelViewT.text=self.LabelArray[0];

break;

case 1:

cell.ImageViewT.image=[UIImage imageNamed:self.PicArray[indexPath.row+1]];

cell.LabelViewT.text=self.LabelArray[indexPath.row+1];

break;

case 2:

cell.ImageViewT.image=[UIImage imageNamed:self.PicArray[indexPath.row+5]];

cell.LabelViewT.text=self.LabelArray[indexPath.row+5];

break;

default:

break;

}

return cell;

}

//点击跳转

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

if(indexPath.section==0){

[self performSegueWithIdentifier:@"1" sender:indexPath];

}else if(indexPath.section==1){

switch (indexPath.row) {

case 0:

[self performSegueWithIdentifier:@"2" sender:indexPath];

break;

case 1:

[self performSegueWithIdentifier:@"3" sender:indexPath];

break;

default:

break;

}

}else

[self performSegueWithIdentifier:@"7" sender:indexPath];

}

//cell  头顶距离

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{

return 20;

}

//tableView 最后的颜色

//-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{

////    UIView *view=[[UITableView alloc]init];

//    UIView *view=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, 20, 100)];

//    view.backgroundColor=[UIColor lightGrayColor];

//    return view;

//}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{

return 20;

}

ps:自定义cell要给它创建一个UITableViewCell , cell中要实现方法的 可以直接拖到当前控制器

实现TabelView的多个cell布局的更多相关文章

  1. UICollectionView自定义cell布局layout

    写一个类继承UICollectionViewLayout,这个类需要提供一个数组来标识各个cell的属性信息,包括位置,size大小,返回一个UICollectionViewLayoutAttribu ...

  2. 【iOS开发-68】APP下载案例:利用tableView自带的cell布局+缓存池cell复用时注意button状态的检查

    (1)效果 (2)源码与资源下载 http://pan.baidu.com/s/1pJLo2PP (3)总结 --核心是利用UITableView里面自带的cell来制作样式同样的cell. 与之对应 ...

  3. [How to] 动态布局可变高度的cell的应用

    1.简介 代码:https://github.com/xufeng79x/DynamicChangeableCell 微博界面,微信和QQ聊天界面,这些界面的布局大都不确定,且每一条消息的高度也不一样 ...

  4. 自定义cell

    思路就是创建模型,自定义cell,然后在主控制器中完成,首先要观察plist文件: Contact.h #import <Foundation/Foundation.h> @interfa ...

  5. iOS深入学习(UITableView系列4:使用xib自定义cell)

    可以通过继承UITableViewCell重新自定义cell,可以像下面一样通过代码来自定义cell,但是手写代码总是很浪费时间, ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ...

  6. 触控(Touch) 、 布局(Layout)

    1 使用触控实现一个简易的画板 1.1 问题 触控(Touch)是一个UITouch类型的对象,当用户触摸了屏幕上的视图时自动被创建,通常使用触控实现绘图.涂鸦.手写等功能.本案例使用触控实现一个简易 ...

  7. iOS学习之UI自定义cell

    一.自定义Cell 为什么需要自定义cell:系统提供的cell满足不了复杂的样式,因此:自定义Cell和自定义视图一样,自己创建一种符合我们需求的Cell并使用这个Cell.如下图所示的这些Cell ...

  8. iOS 8自动调整UITableView和UICollectionView布局

    本文转载自:http://tech.techweb.com.cn/thread-635784-1-1.html 本文讲述了UITableView.UICollectionView实现 self-siz ...

  9. 详细分享UICollectionView的自定义布局(瀑布流, 线性, 圆形…)

    前言: 本篇文章不是分享collectionView的详细使用教程, 而是属于比较’高级’的collectionView使用技巧, 阅读之前, 我想你已经很熟悉collectionView的基本使用, ...

随机推荐

  1. discuz手机版模板开发

    1.触屏版模板手机路径 discuz X3触屏版模板路径:/template/default/touch/forum/discuz.htm(主页面模板) discuz X3标准版模板路径:/templ ...

  2. sphinx索引分析——文件格式和字典是double array trie 检索树,索引存储 – 多路归并排序,文档id压缩 – Variable Byte Coding

    1 概述 这是基于开源的sphinx全文检索引擎的架构代码分析,本篇主要描述index索引服务的分析.当前分析的版本 sphinx-2.0.4 2 index 功能 3 文件表 4 索引文件结构 4. ...

  3. python二进制相关

    https://docs.python.org/3/library/struct.html#module-struct

  4. VC环境配置办法

    在VS工程中,添加c/c++工程中外部头文件及库的基本步骤:1.添加工程的头文件目录:工程---属性---配置属性---c/c++---常规---附加包含目录:加上头文件存放目录.2.添加文件引用的l ...

  5. 用C#实现的内存映射

    当文件过大时,无法一次性载入内存时,就需要分次,分段的载入文件 主要是用了以下的WinAPI LPVOID MapViewOfFile(HANDLE hFileMappingObject, DWORD ...

  6. java给不同步的集合加上同步锁

    给非同步的集合加锁: class MyCollections{//创建工具类,提供对外访问方法 public static list synList(List list){ return new My ...

  7. SQL Server数据库性能优化之索引篇【转】

    http://www.blogjava.net/allen-zhe/archive/2010/07/23/326966.html 性能优化之索引篇 近期项目需要, 做了一段时间的SQL Server性 ...

  8. 转-IE浏览器自动配置代理脚本-Proxy.PAC文件及PAC相关语法

    用笔记本上网时,往返家里和单位,因为单位是用的代理上网,家里是直接连接.因此每次都要修改IE的代理设置,虽然是个小事,但是每次都要修改总是有点烦 ,于是参考GOOGLE,写了一个自动配置代理的脚本.这 ...

  9. Python Day 01

    What is variables? 一段命名的内存空间 变量即在程序运行过程中,它的值是允许改变的量 1.变量命名: 合法: 显式.通俗易懂. nums_of_jay_gf = 19 NumsOfJ ...

  10. c++学习笔记1

    1.explicit 防止隐式类型转换 2.cbegin() cend()等价于返回 const_iterator 类型 3.it->mem 等价于 (*it).mem 4.不允许使用一个数组初 ...