*:first-child {
margin-top: 0 !important; }
body > *:last-child {
margin-bottom: 0 !important; }

a {
color: #4183C4; }
a.absent {
color: #cc0000; }
a.anchor {
display: block;
padding-left: 30px;
margin-left: -30px;
cursor: pointer;
position: absolute;
top: 0;
left: 0;
bottom: 0; }

h1, h2, h3, h4, h5, h6 {
margin: 20px 0 10px;
padding: 0;
font-weight: bold;
-webkit-font-smoothing: antialiased;
cursor: text;
position: relative; }

h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor, h5:hover a.anchor, h6:hover a.anchor {
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA09pVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoMTMuMCAyMDEyMDMwNS5tLjQxNSAyMDEyLzAzLzA1OjIxOjAwOjAwKSAgKE1hY2ludG9zaCkiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6OUM2NjlDQjI4ODBGMTFFMTg1ODlEODNERDJBRjUwQTQiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6OUM2NjlDQjM4ODBGMTFFMTg1ODlEODNERDJBRjUwQTQiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo5QzY2OUNCMDg4MEYxMUUxODU4OUQ4M0REMkFGNTBBNCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo5QzY2OUNCMTg4MEYxMUUxODU4OUQ4M0REMkFGNTBBNCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PsQhXeAAAABfSURBVHjaYvz//z8DJYCRUgMYQAbAMBQIAvEqkBQWXI6sHqwHiwG70TTBxGaiWwjCTGgOUgJiF1J8wMRAIUA34B4Q76HUBelAfJYSA0CuMIEaRP8wGIkGMA54bgQIMACAmkXJi0hKJQAAAABJRU5ErkJggg==) no-repeat 10px center;
text-decoration: none; }

h1 tt, h1 code {
font-size: inherit; }

h2 tt, h2 code {
font-size: inherit; }

h3 tt, h3 code {
font-size: inherit; }

h4 tt, h4 code {
font-size: inherit; }

h5 tt, h5 code {
font-size: inherit; }

h6 tt, h6 code {
font-size: inherit; }

h1 {
font-size: 28px;
color: black; }

h2 {
font-size: 24px;
border-bottom: 1px solid #cccccc;
color: black; }

h3 {
font-size: 18px; }

h4 {
font-size: 16px; }

h5 {
font-size: 14px; }

h6 {
color: #777777;
font-size: 14px; }

p, blockquote, ul, ol, dl, li, table, pre {
margin: 15px 0; }

hr {
background: transparent url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAAECAYAAACtBE5DAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBNYWNpbnRvc2giIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6OENDRjNBN0E2NTZBMTFFMEI3QjRBODM4NzJDMjlGNDgiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6OENDRjNBN0I2NTZBMTFFMEI3QjRBODM4NzJDMjlGNDgiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo4Q0NGM0E3ODY1NkExMUUwQjdCNEE4Mzg3MkMyOUY0OCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo4Q0NGM0E3OTY1NkExMUUwQjdCNEE4Mzg3MkMyOUY0OCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PqqezsUAAAAfSURBVHjaYmRABcYwBiM2QSA4y4hNEKYDQxAEAAIMAHNGAzhkPOlYAAAAAElFTkSuQmCC) repeat-x 0 0;
border: 0 none;
color: #cccccc;
height: 4px;
padding: 0;
}

body > h2:first-child {
margin-top: 0;
padding-top: 0; }
body > h1:first-child {
margin-top: 0;
padding-top: 0; }
body > h1:first-child + h2 {
margin-top: 0;
padding-top: 0; }
body > h3:first-child, body > h4:first-child, body > h5:first-child, body > h6:first-child {
margin-top: 0;
padding-top: 0; }

a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 {
margin-top: 0;
padding-top: 0; }

h1 p, h2 p, h3 p, h4 p, h5 p, h6 p {
margin-top: 0; }

li p.first {
display: inline-block; }
li {
margin: 0; }
ul, ol {
padding-left: 30px; }

ul :first-child, ol :first-child {
margin-top: 0; }

dl {
padding: 0; }
dl dt {
font-size: 14px;
font-weight: bold;
font-style: italic;
padding: 0;
margin: 15px 0 5px; }
dl dt:first-child {
padding: 0; }
dl dt > :first-child {
margin-top: 0; }
dl dt > :last-child {
margin-bottom: 0; }
dl dd {
margin: 0 0 15px;
padding: 0 15px; }
dl dd > :first-child {
margin-top: 0; }
dl dd > :last-child {
margin-bottom: 0; }

blockquote {
border-left: 4px solid #dddddd;
padding: 0 15px;
color: #777777; }
blockquote > :first-child {
margin-top: 0; }
blockquote > :last-child {
margin-bottom: 0; }

table {
padding: 0;border-collapse: collapse; }
table tr {
border-top: 1px solid #cccccc;
background-color: white;
margin: 0;
padding: 0; }
table tr:nth-child(2n) {
background-color: #f8f8f8; }
table tr th {
font-weight: bold;
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }
table tr td {
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }
table tr th :first-child, table tr td :first-child {
margin-top: 0; }
table tr th :last-child, table tr td :last-child {
margin-bottom: 0; }

img {
max-width: 100%; }

span.frame {
display: block;
overflow: hidden; }
span.frame > span {
border: 1px solid #dddddd;
display: block;
float: left;
overflow: hidden;
margin: 13px 0 0;
padding: 7px;
width: auto; }
span.frame span img {
display: block;
float: left; }
span.frame span span {
clear: both;
color: #333333;
display: block;
padding: 5px 0 0; }
span.align-center {
display: block;
overflow: hidden;
clear: both; }
span.align-center > span {
display: block;
overflow: hidden;
margin: 13px auto 0;
text-align: center; }
span.align-center span img {
margin: 0 auto;
text-align: center; }
span.align-right {
display: block;
overflow: hidden;
clear: both; }
span.align-right > span {
display: block;
overflow: hidden;
margin: 13px 0 0;
text-align: right; }
span.align-right span img {
margin: 0;
text-align: right; }
span.float-left {
display: block;
margin-right: 13px;
overflow: hidden;
float: left; }
span.float-left span {
margin: 13px 0 0; }
span.float-right {
display: block;
margin-left: 13px;
overflow: hidden;
float: right; }
span.float-right > span {
display: block;
overflow: hidden;
margin: 13px auto 0;
text-align: right; }

code, tt {
margin: 0 2px;
padding: 0 5px;
white-space: nowrap;
border: 1px solid #eaeaea;
background-color: #f8f8f8;
border-radius: 3px; }

pre code {
margin: 0;
padding: 0;
white-space: pre;
border: none;
background: transparent; }

.highlight pre {
background-color: #f8f8f8;
border: 1px solid #cccccc;
font-size: 13px;
line-height: 19px;
overflow: auto;
padding: 6px 10px;
border-radius: 3px; }

pre {
background-color: #f8f8f8;
border: 1px solid #cccccc;
font-size: 13px;
line-height: 19px;
overflow: auto;
padding: 6px 10px;
border-radius: 3px; }
pre code, pre tt {
background-color: transparent;
border: none; }

sup {
font-size: 0.83em;
vertical-align: super;
line-height: 0;
}
* {
-webkit-print-color-adjust: exact;
}
@media screen and (min-width: 914px) {
body {
width: 854px;
margin:0 auto;
}
}
@media print {
table, pre {
page-break-inside: avoid;
}
pre {
word-wrap: break-word;
}
}
-->
code[class*="language-"],
pre[class*="language-"] {
background: #f5f2f0;
}

/* Inline code */
:not(pre) > code[class*="language-"] {
padding: .1em;
border-radius: .3em;
white-space: normal;
}

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: slategray;
}

.token.punctuation {
color: #999;
}

.namespace {
opacity: .7;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
color: #905;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
color: #690;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
color: #a67f59;
background: hsla(0, 0%, 100%, .5);
}

.token.atrule,
.token.attr-value,
.token.keyword {
color: #07a;
}

.token.function {
color: #DD4A68;
}

.token.regex,
.token.important,
.token.variable {
color: #e90;
}

.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}

.token.entity {
cursor: help;
}
-->


时间:2015年11月23日  感谢MJ老师,感谢朱黄辰老师

内容大纲:

1、初识UITableView和UITableViewDataSource
2、使用UITableViewDataSource做小实例展示多组数据
3、常见属性
4、性能优化
5、性能优化的使用注意
6、Cell的重用原理
7、注册cell
8、索引条
9、关于UITableViewController
10、附录

1、初识UITableView和UITableViewDataSource

继承自UIScrollView

  • 如何展示数据:

    • 需要一个数据源(UITableViewDataSource),接受这个协议,然后实现必须要实现的方法
    • UITableView会向数据源查询一共有多少行数据以及每一行显示什么数据等
    • 没有设置数据源的UITableView只是一个空壳
    • 但凡遵守UITableViewDataSource的OC对象,都可以是UITableView的数据源

      简单实现协议里的方法实例:

  • UITableViewStylePlain:平板格式             UITableViewStyleGrouped:分组格式

    其中需要积累的两个小知识点,至少要知道意思,不然用到这点知识不知道怎么用不行的:

    1、NSIndexPath对象,有两个属性
    indexPath.section == 1 组号
    indexPath.row == 2 行号 2、(NSInteger对象的占位符是%zd,对象地址的占位符是%p)

向上移动header会保留在上方直到这个组完全不在视野内 ,向下移动fooder会保留在底部直到这个组完全不在视野内

托线添加数据源或代理:

如果需要添加UITableView组的头部尾部描述信息,可以command+点击协议里找需要重写的方法,同样,如果需要查看UITableViewDelegate的代理的方法,也可以在代理里的源码看方法,这也是一种常用的自学不管是苹果提供的还是第三方框架框架使用的学习方法。

如果在每一行显示的内容中,也就是上面实现协议的第三个方法中,如果涉及要设置cell的accessroyType的显示样式

accessory n. 附件, 配件

  • cell.accessroyType = UITableViewCellAccessory......
  • cell.accessroyView = [[UISwitch alloc] init];

如果在代码中使用以上两种,不论顺序如何,比如上面的,最后的顺序都是现实UI控件,因为UI控件设置优先级比较高。

2、使用UITableViewDataSource做小实例展示多组数据

通过重写协议里的方法来实现:

使用模型改进数据并已经进行了后面提到的cell循环利用的优化的源代码下载:

百度云 链接:http://pan.baidu.com/s/1hqubma4 密码: vkdz

3、常见属性

常见属性有个大致印象就好,先上图一览用到的方法,后面的代码过一遍即可

 #import "ViewController.h"
#import "XMGWine.h" @interface ViewController () <UITableViewDataSource, UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
/** 酒数据 */
@property (nonatomic, strong) NSArray *wineArray;
@end @implementation ViewController - (NSArray *)wineArray
{
if (!_wineArray) {
// 加载字典数组
NSArray *dictArray = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"wine.plist" ofType:nil]]; // 将字典数组 -> 模型数据
NSMutableArray *wineArray = [NSMutableArray array];
for (NSDictionary *dict in dictArray) {
[wineArray addObject:[XMGWine wineWithDict:dict]];
} _wineArray = wineArray;
}
return _wineArray;
} - (void)viewDidLoad {
[super viewDidLoad]; self.tableView.delegate = self; // 设置每一行cell的高度
self.tableView.rowHeight = ; // 设置每一组头部的高度
self.tableView.sectionHeaderHeight = ; // 设置每一组尾部的高度
// self.tableView.sectionFooterHeight = 50; // 设置分割线颜色
self.tableView.separatorColor = [UIColor redColor];
// 设置分割线样式
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; // 设置表头控件
self.tableView.tableHeaderView = [[UISwitch alloc] init];
// 设置表尾控件
self.tableView.tableFooterView = [UIButton buttonWithType:UIButtonTypeContactAdd];
} #pragma mark - <UITableViewDataSource>
// 如果不实现这个数据源方法,那么就是1组数据
//- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
//{
// return 1;
//} - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.wineArray.count;
} - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// 创建一个UITableViewCellStyleSubtitle样式的cell
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil]; // 取出indexPath位置对应的XMGWine模型
XMGWine *wine = self.wineArray[indexPath.row]; // 设置数据
cell.imageView.image = [UIImage imageNamed:wine.image];
cell.textLabel.text = wine.name;
cell.detailTextLabel.text = [NSString stringWithFormat:@"¥%@", wine.money];
cell.detailTextLabel.textColor = [UIColor orangeColor];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; // 设置cell的选中样式
// cell.selectionStyle = UITableViewCellSelectionStyleNone; // backgroundView优先级 > backgroundColor // 设置背景色
cell.backgroundColor = [UIColor redColor]; // 设置背景view
UIView *bg = [[UIView alloc] init];
bg.backgroundColor = [UIColor blueColor];
cell.backgroundView = bg; // 设置选中的背景view
UIView *selectedBg = [[UIView alloc] init];
selectedBg.backgroundColor = [UIColor purpleColor];
cell.selectedBackgroundView = selectedBg; return cell;
} //- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
//{
// return @"头部";
//} #pragma mark - <UITableViewDelegate>
/**
* 当选中一行的时候调用(点击)
*/
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// XMGWine *wine = self.wineArray[indexPath.row];
// NSLog(@"点击了:%@", wine.name);
NSLog(@"选中了:%zd", indexPath.row);
} /**
* 当取消选中一行的时候调用
*/
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"取消选中了:%zd", indexPath.row);
} - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
return [UIButton buttonWithType:UIButtonTypeInfoDark];
} - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
return [[UISwitch alloc] init];
} //- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
//{
// if (section == 0) return 20;
// if (section == 1) return 50;
//} /**
* 返回每个cell的高度
*/
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row % == ) {
return ;
} else {
return ;
}
}
@end

<==源代码点击就能打开查看

另外,如果你想要隐藏状态栏,你可以直接重写下面的方法,并返回YES

我个人在敲代码的时候遇到容易失误的地方,我自己引以为鉴,路人可以飘过:

4、性能优化

出于性能优化考虑:如果有200个cell,如果全部加载好了,那么界面以外还没显示的就太浪费了,所以就需要懒加载,等马上要显示,就加载需要的,苹果这一点已经给我们内置做好了这个优化,下面我们来测试验证一下懒加载的优化结果:

首先,我们都知道,每当有一个cell要进入视野范围内,就会调用一次的方法,所以我在这个方法内添加打印创建cell的内存地址的方法:

然后通过打印创建的cell的内存地址来看看其在内存的情况,然后推断性能好不好。

所以,拖拽TableView,是会频繁的创建和销毁。创建即将显示的cell,销毁已经不显示的cell。这个就是数据结构里的队列思想,先进先出,后进后出。只不过要改一改,先进先销毁,后进后销毁。只不过,频繁的创建和销毁也是耗费内存的计算复杂度的,也会耗费CPU的计算资源。

其实,还可以有更好的优化的方法:将cell循环利用。

循环利用的思想概括:假如屏幕最多刚好显示出7个cell,分别是1~7个cell,然后向上拖拽TableView,第8个即将显示,当然会创建出第8个 cell,这时候,第1个即将消失,到了完全消失的时候,利用用系统已经内置好的缓冲池,将这个第1个cell放置在缓冲池中不销毁,然后继续往上拖拽 TableView当第9个即将显示创建出来的时候,不是通过alloc init开辟新的内存空间创建的,而是直接将缓冲池之间存储的第一个cell拿过来用,然后仅仅要做的就是在这个cell上重新加载显示数据。这样循环利 用cell,可以很好地节约内存空间复杂度和内存的运行时间复杂度。

下面就在上面的实例将其循环利用cell的思想实现:

上动态图看看:

然后上静态图看结果:

5、性能优化的使用注意

1、标签取名与源数据相关而且有意义的。比如跟酒的数据相关的就用:NSString *ID = @"wine";

2、使用static NSString *ID = @"wine"; 使得ID只会创建一次

3、也可以使用全局,但是不建议,以为全局外部也可以访问那个全局数据。

4、在循环利用的代码里,因为那段设置每一行显示内容的方法会被频繁的调用,所以相同的代码最好写在if(!cell)语句里,而需要动态加载数据的不同的方法写在if(!cell)语句之外。

5、循环利用注意事项, 额外的if语句(不是if(!cell)的语句)有if肯定有else,因为只有if的话,又因为循环重复利用的特点,会使得所有if语句中的数据同化。

下面见证奇迹的时刻到了:

所以要把else补上。

6、Cell的重用原理

lOS设备的内存有限,如果用UITableView显示成千上万条数据,就需要成千上万个UITableViewCell对象的话,那将会耗尽iOS设备的内存。要解决该问题,需要重用UITableViewCell对象
 
重用原理:当滚动列表时,部分UITableViewCell会移出窗口,UITableView会将窗口外的UITableViewCell放入一个对象池中,等待重用。当UITableView要求dataSource返回UITableViewCell时,dataSource会先查看这个对象池,如果池中有未使用的UITableViewCell,dataSource会用新的数据配置这个UITableViewCell,然后返回给UITableView,重新显示到窗口中,从而避免创建新对象
 
还有一个非常重要的问题:有时候需要自定义UITableViewCell(用一个子类继承UITableViewCell),而且每一行用的不一定是同一种UITableViewCell,所以一个UITableView可能拥有不同类型的UITableViewCell,对象池中也会有很多不同类型的UITableViewCell,那么UITableView在重用UITableViewCell时可能会得到错误类型的UITableViewCell
 
解决方案:UITableViewCell有个NSString *reuseIdentifier属性,可以在初始化UITableViewCell的时候传入一个特定的字符串标识来设置reuseIdentifier(一般用UITableViewCell的类名)。当UITableView要求dataSource返回UITableViewCell时,先通过一个字符串标识到对象池中查找对应类型的UITableViewCell对象,如果有,就重用,如果没有,就传入这个字符串标识来初始化一个UITableViewCell对象

7、注册cell

和前面第一种优化方案相比,在创建cell对象的时候,第二种方案没法设定cell的样式,也就是会保持默认的样式。

但是这个也是有解决方案的,可以通过xib自定义cell,自定义cell组件可以包含自己想要的子控件,而且还可以动态的更改设置,然后创建自定义cell就可以了。

这里给出cell的样式一览:

8、索引条

首先在plist文件对于归类的数据,另外可以添加专门用于显示在组头和索引条上的字母。

这个plist文件等会会提供的项目源码中会有,包括plist文件对应的数据也在项目中

然后重写下面的方法,

另外可以在viewDidLoad方法中设置索引条样式

显示的效果:

项目源码链接: http://pan.baidu.com/s/1bnFQjOb 密码: hixf

9、关于UITableViewController

 在使用UITableView的所有功能,其实只要UITableViewController,很多事就做好了。所以接下来就直接使用
 继承UITableViewController,然后storyboard拖一个UITableViewController的控件,然后class改为ViewController 然后实现两个方法即可。
 
 

10、附录相关下载资源

关于上面展示过的车辆品牌展示的项目的练习资源,其实前面提供了项目下载,项目里面也有,但是这里还是提供直接下载的,这里还配备图片资源哦,练习的时候,可以把图片加载到cell里去:

链接: http://pan.baidu.com/s/1mgMtybe 密码: j4dp

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

最新文章

  1. 如果你发现mysql的外键约束不管用了
  2. php 用户ip的获取
  3. strcmp的实现
  4. 一个好用且方便的FastCgi C++库 - FastCgi++
  5. 【转】Java基础笔记 – 枚举类型的使用介绍和静态导入--不错
  6. FileInputStream(字节流)与fileReader(字符流) 的区别
  7. 动态得到WCF的代理类并生成代码
  8. SPRING AOP ....0 can&#39;t find referenced pointcut
  9. 团队作业4——第一次项目冲刺(Alpha版本) 2017.4.23
  10. ValueError: too many values to unpack (expected 2)
  11. Django auth认证
  12. python数据处理excel和pdf,并打包成exe
  13. js 学习之路5:使用js在网页中添加水印
  14. 8.快速索引、listview
  15. 【转】利用Boost.Python将C++代码封装为Python模块
  16. Golang的格式化输出fmt.Printf
  17. mysql中if()函数使用
  18. MRBS开源会议室预订系统安装
  19. Oracle性能诊断艺术-学习笔记(索引访问方式)
  20. case when then end 用法

热门文章

  1. java中产生对象的两种方式
  2. [OpenCV] Feature Extraction
  3. [转载]AxureRP 7超强部件库下载
  4. An Introduction to Garbage Collection(垃圾回收简介)
  5. Java魔法堂:String.format详解
  6. 准备.Net转前端开发-WPF界面框架那些事,搭建基础框架
  7. 从零开始,CentOS6安装ghost博客
  8. 快捷获取浏览器(navigator对象)的全部属性
  9. 邻接矩阵c源码(构造邻接矩阵,深度优先遍历,广度优先遍历,最小生成树prim,kruskal算法)
  10. [翻译]:SQL死锁-锁与事务级别