IOS第七天(4:UiTableView 数据的显示优化重复实例和tableFooterView和tableHeaderView)
//加上头部 和底部
- (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)的更多相关文章
- IOS第七天(3:UiTableView 模型和数据的分组的显示)
*************UiTableView模型和数据的分组的显示 #import "HMViewController.h" #import "HMHero.h&qu ...
- IOS第七天(2:UiTableView 加上数据分离)
****加上数据分离 #import "HMViewController.h" #import "HMStudent.h" @interface HMViewC ...
- IOS第七天(6:UiTableView编辑模式, 拖动位置 ,滑动删除)
**********UiTableView编辑模式, 拖动位置 ,滑动删除 #import "HMViewController.h" @interface HMViewContro ...
- IOS第七天(5:UiTableView 汽车品牌,复杂模型分组展示,A-Z索要列表) (2015-08-05 14:03)
复杂模型分组展示 #import "HMViewController.h" #import "HMCarGroup.h" #import "HMCar ...
- IOS第七天(1:UiTableView 的基本用法)
***表格控件 #import "HMViewController.h" @interface HMViewController () <UITableViewDataSou ...
- iOS全埋点解决方案-UITableView和UICollectionView点击事件
前言 在 $AppClick 事件采集中,还有两个比较特殊的控件: UITableView •UICollectionView 这两个控件的点击事件,一般指的是点击 UITableViewCell 和 ...
- iOS开发UI篇—实现UItableview控件数据刷新
iOS开发UI篇—实现UItableview控件数据刷新 一.项目文件结构和plist文件 二.实现效果 1.说明:这是一个英雄展示界面,点击选中行,可以修改改行英雄的名称(完成数据刷新的操作). 运 ...
- iOS开发UI篇—使用UItableview完成一个简单的QQ好友列表(一)
iOS开发UI篇—使用UItableview完成一个简单的QQ好友列表(一) 一.项目结构和plist文件 二.实现代码 1.说明: 主控制器直接继承UITableViewController // ...
- iOS开发UI篇—在UITableview的应用中使用动态单元格来完成app应用程序管理界面的搭建
iOS开发UI篇—在UITableview的应用中使用动态单元格来完成app应用程序管理界面的搭建 一.实现效果 说明:该示例在storyboard中使用动态单元格来完成. 二.实现 1.项目文件结构 ...
随机推荐
- node http 服务
var http = require("http") http.createServer(function(req,res){ res.writeHead(200,{"C ...
- S5中新增的Array方法详细说明
ES5中新增的Array方法详细说明 by zhangxinxu from http://www.zhangxinxu.com 本文地址:http://www.zhangxinxu.com/wor ...
- How to: 使用 数据流 实现生产者-消费者模式
producer把消息发送到消息块,consumer从块读取消息. 安装: Install-Package Microsoft.Tpl.Dataflow using System.Thread ...
- 快速傅里叶变换FFT学习小记
FFT学得还是有点模糊,原理那些基本还是算有所理解了吧,不过自己推这个推不动. 看的资料主要有这两个: http://blog.miskcoo.com/2015/04/polynomial-multi ...
- linux中用shell获取时间,日期
linux中用shell获取昨天.明天或多天前的日期:在Linux中对man date -d 参数说的比较模糊,以下举例进一步说明:# -d, --date=STRING display time d ...
- Codeforces Round #210 (Div. 2) A. Levko and Table
让对角线的元素为k就行 #include <iostream> using namespace std; int main() { int n,k; cin >> n > ...
- NOIP欢乐模拟赛 T3 解题报告
3.小澳的葫芦 (calabash.cpp/c/pas) [题目描述] 小澳最喜欢的歌曲就是<葫芦娃>. 一日表演唱歌,他尽了洪荒之力,唱响心中圣歌. 随之,小澳进入了葫芦世界. 葫芦世界 ...
- HDU 4722 Good Numbers(DP)
题目链接 脑子有点乱,有的地方写错了,尚大婶鄙视了... 来个模版的. #include <iostream> #include <cstdio> #include <c ...
- locale的设定及其LANG、LC_ALL、LANGUAGE环境变量的区别
locale这个单词中文翻译成地区或者地域,其实这个单词包含的意义要宽泛很多.Locale是根据计算机用户所使用的语言,所在国家或者地区,以及当地的文化传统所定义的一个软件运行时的语言环境. [ora ...
- AJAX-跨域解决之 JSONP
(一)AJAX ajax 就是从某个文件中去找相关的数据,把数据拿过来以后,利用数据 分析数据 去做我们想做的事情 分两部分:拿数据 用数据 oUsername ...