//加上头部 和底部

- (void)viewDidLoad
{
[super viewDidLoad]; [self tableView]; // 设置行高
self.tableView.rowHeight = ; // 分隔线
self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
/**
32位真彩色 ARGB 2^8 * 2^8 * 2^8 * 2^8 = 2^32 = 2^2 * 2^10 * 2^10 * 2^10 = 4G
2^64 = 16 GG A = Alpha
R
G
B
24位真彩色 RGB 2^8 * 2^8 * 2^8 = 2 ^ 24 = 2^4 * 2^10 = 16 * 100万
R = Red 1个字节 8位 0~255
G = Green
B = Blun # ff ff ff ff
*/
self.tableView.separatorColor = [UIColor colorWithWhite:0.0 alpha:0.2]; // headView,放在tableView最顶部的视图,通常用来放图片轮播器
UIView *head = [[UIView alloc] initWithFrame:CGRectMake(, , , )];
head.backgroundColor = [UIColor blueColor];
self.tableView.tableHeaderView = head; // footerView,通常做上拉刷新
UIView *foot = [[UIView alloc] initWithFrame:CGRectMake(, , , )];
foot.backgroundColor = [UIColor redColor];
self.tableView.tableFooterView = foot;
}

//优化 cell 复用view

 // 0. 可重用标示符字符串
// static静态变量,能够保证系统为变量在内存中只分配一次内存空间
// 静态变量,一旦创建,就不会被释放,只有当应用程序被销毁时,才会释放!
static NSString *ID = @"Cell"; // 1. 取缓存池查找可重用的单元格
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; // 2. 如果没有找到
if (cell == nil) {
NSLog(@"实例化单元格");
// 创建单元格,并设置cell有共性的属性 // 实例化新的单元格
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID]; // 右侧箭头
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; // 背景颜色,会影响到未选中表格行的标签背景
// cell.backgroundColor = [UIColor redColor];
// 在实际开发中,使用背景视图的情况比较多
// 背景视图,不需要指定大小,cell会根据自身的尺寸,自动填充调整背景视图的显示
// UIImage *bgImage = [UIImage imageNamed:@"img_01"];
// cell.backgroundView = [[UIImageView alloc] initWithImage:bgImage];
// UIView *bgView = [[UIView alloc] init];
// bgView.backgroundColor = [UIColor yellowColor];
// cell.backgroundView = bgView;
// 没有选中的背景颜色
// 选中的背景视图
// UIImage *selectedBGImage = [UIImage imageNamed:@"img_02"];
// cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:selectedBGImage];
}

IOS第七天(4:UiTableView 数据的显示优化重复实例和tableFooterView和tableHeaderView)的更多相关文章

  1. IOS第七天(3:UiTableView 模型和数据的分组的显示)

    *************UiTableView模型和数据的分组的显示 #import "HMViewController.h" #import "HMHero.h&qu ...

  2. IOS第七天(2:UiTableView 加上数据分离)

    ****加上数据分离 #import "HMViewController.h" #import "HMStudent.h" @interface HMViewC ...

  3. IOS第七天(6:UiTableView编辑模式, 拖动位置 ,滑动删除)

    **********UiTableView编辑模式, 拖动位置 ,滑动删除 #import "HMViewController.h" @interface HMViewContro ...

  4. IOS第七天(5:UiTableView 汽车品牌,复杂模型分组展示,A-Z索要列表) (2015-08-05 14:03)

    复杂模型分组展示 #import "HMViewController.h" #import "HMCarGroup.h" #import "HMCar ...

  5. IOS第七天(1:UiTableView 的基本用法)

    ***表格控件 #import "HMViewController.h" @interface HMViewController () <UITableViewDataSou ...

  6. iOS全埋点解决方案-UITableView和UICollectionView点击事件

    前言 在 $AppClick 事件采集中,还有两个比较特殊的控件: UITableView •UICollectionView 这两个控件的点击事件,一般指的是点击 UITableViewCell 和 ...

  7. iOS开发UI篇—实现UItableview控件数据刷新

    iOS开发UI篇—实现UItableview控件数据刷新 一.项目文件结构和plist文件 二.实现效果 1.说明:这是一个英雄展示界面,点击选中行,可以修改改行英雄的名称(完成数据刷新的操作). 运 ...

  8. iOS开发UI篇—使用UItableview完成一个简单的QQ好友列表(一)

    iOS开发UI篇—使用UItableview完成一个简单的QQ好友列表(一) 一.项目结构和plist文件 二.实现代码 1.说明: 主控制器直接继承UITableViewController // ...

  9. iOS开发UI篇—在UITableview的应用中使用动态单元格来完成app应用程序管理界面的搭建

    iOS开发UI篇—在UITableview的应用中使用动态单元格来完成app应用程序管理界面的搭建 一.实现效果 说明:该示例在storyboard中使用动态单元格来完成. 二.实现 1.项目文件结构 ...

随机推荐

  1. 从Sql server 2008获取表字段属性信息,注释信息

    select   b.[value] from sys.columns a left join sys.extended_properties b on a.object_id=b.major_id  ...

  2. Dijkstra(变形) POJ 1797 Heavy Transportation

    题目传送门 题意:求1到n的最大载重量 分析:那么就是最大路上的最小的边权值,改变优先规则. #include <cstdio> #include <algorithm> #i ...

  3. Golang 安装及配置教程 for Mac

    1.到golang.org下载golang 并安装. 2.安装sublimetext ,打开之后 按ctrl+` 打开命令行,输入以下内容: import urllib2,os; pf='Packag ...

  4. adams/car 怎么进入template builder模块

    打开C:\Documents and Settings\Administrator文件夹下的acar.cfg文件,将 Desired user mode (standard/expert)ENVIRO ...

  5. Visual Studio 2010: 调试引用的dll的代码?

    right click the solution in the Solution Explorer-> Properties->  Debug ->Enable Debuggers- ...

  6. 【转】crontab定时任务中文乱码问题

    转载:http://blog.163.com/rettar@126/blog/static/1216503422012135511740/ 手动执行都很正常的的脚步,添加到定时任务中一直执行失败,日志 ...

  7. sed 格式化输出df -h

    df -h|sed '1d;/ /!N;s/\n//;s/ \+/ /;' 1d——————删除第一行 / /!N——————没有空格的行执行N 例子中没有空格的行 /dev/mapper/vg_ds ...

  8. topcoder SRM 622 DIV2 BoxesDiv2

    注意题目这句话,Once you have each type of candies in a box, you want to pack those boxes into larger boxes, ...

  9. ACM 房间安排

    房间安排 时间限制:3000 ms  |  内存限制:65535 KB 难度:2   描述 2010年上海世界博览会(Expo2010),是第41届世界博览会.于2010年5月1日至10月31日期间, ...

  10. 应用程序间跳转 (友盟SSO 授权 与系统自带的分享)

    应用程序间跳转的应用场景 使用第三方用户登录,如微信登录,返回用户名和密码 需要用户授权,返回到调用程序,同时返回授权的用户名 应用程序推广,跳转到itunes并显示指定app下载页 第三方支付,跳转 ...