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.项目文件结构 ...
随机推荐
- Find Minimum in Rotated Sorted Array
package leetcode; /* * * 注意问题: * 1. 原序列升序.降序问题,两种情况都要考虑 * 2. 边界问题,如果只有两个元素时要单独考虑,在num[mid]==num[left ...
- AngularJS进阶学习
参考:http://***/class/54f3ba65e564e50cfccbad4b 1. AJAX:Asynchronous JavaScript and XML(异步的 JavaScript ...
- Andriod开发技巧——Fragment的懒加载
我们在做应用开发的时候,一个Activity里面可能会以viewpager(或其他容器)与多个Fragment来组合使用,而如果每个 fragment都需要去加载数据,或从本地加载,或从网络加载,那么 ...
- Codeforces Round #352 (Div. 2) B - Different is Good
A wise man told Kerem "Different is good" once, so Kerem wants all things in his life to b ...
- [Leetcode|SQL] Combine Two Tables
Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...
- The Beatles-Hey Jude
轉載自 https://www.youtube.com/watch?v=V3jCYm_QGZQ Hey Jude, don't make it bad.Take a sad song and make ...
- PHP 高效分布代码转的
在<efficient pagination using mysql>中提出的clue方式. 利用clue方法,给翻页提供一些线索,比如还是SELECT * FROM `csdn` ord ...
- 在不知道json格式的情况下如何使用cjson进行解析
假设我们有一个json字符串,但是我们不知道这个json的组织方式,那么如何进行解析呢,下面就给一个小例子. 1.我们的json串如下: { "aStr": "aaaaa ...
- Facebook通过oAuth验证获取json数据
首先下载facebook相关的动态库,下载文件:facebook.dll 获取授权token方法: private string SetToken(string gettoken)//此处是你的短to ...
- Javascript 异步编程的4种方法
你可能知道,Javascript语言的执行环境是"单线程"(single thread). 所谓"单线程",就是指一次只能完成一件任务.如果有多个任务,就必须排 ...