tableview的两个取得重用cell方法的区别
来源:互联网 发布:ubuntu 14 32位下载 编辑:程序博客网 时间:2024/05/21 16:52
今天在学习IAP的时候无意间看到原来 tableView: cellForRowAtIndexPath:方法中有两个获得重用cell的方法 ,一直以来都是用
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];那下面的这个怎么用呢,感觉比较怪,假设没有重用的岂不是为空了
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]
具体有什么区别呢,并且当我用 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]的时候,为什么总报错
reason:'unable to dequeue a cell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard',经过查阅,知道原来此方法为6.0新加的,在SDK5.0是运行不起来的。
reason:
-(void)registerNib:(UINib *)nib forCellReuseIdentifier:(NSString *)identifier NS_AVAILABLE_IOS(5_0);
-(void)registerClass:(Class)cellClass forCellReuseIdentifier:(NSString *)identifier NS_AVAILABLE_IOS(6_0);
3
self.tableView.backgroundColor = xxxx;
[self.tableView registerClass:[CustomCell class] forCellReuseIdentifier:@"CustomCell"];
这样你在
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath这个方法里,
你就可以省下这些代码:
而只需要
static NSString *CellIdentifier = @"Cell";
UITableViewCell*cell = [tableView dequeueReusableCellWithI dentifier:@"Cell"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefa ult
reuseIdentifier:CellIdentifier];
//设置你的cell
}
而只需要
UITableViewCell ];*cell = [tableView dequeueReusableCellWithI dentifier:@"Cell" forIndexPath:indexPath
//设置你的cell整体来说6.0却是比5.0更省劲
原文:http://blog.csdn.net/wangpotongxue/article/details/9984835
0 0
- tableview的两个取得重用cell方法的区别
- tableview的两个取得重用cell方法的区别
- tableview的两个获得重用cell方法的区别?
- tableview的两个获得重用cell方法的区别
- tableview的两个获得重用cell方法dequeueReusableCellWithIdentifier的区别
- tableview的两个获得重用cell方法的区别?
- tableview的两个重用cell方法
- tableview的两个重用cell方法 (转)
- tableview的两个重用cell方法
- tableView方法中两个重用cell的方法
- tableView: cellForRowAtIndexPath:方法中两个获得重用cell的方法:
- iOS:tableView可重用cell的两个方法
- ios中Tableview的两个获得重用cell方法的区别?(兼容iPhone5.0之前的版本)
- TableView的Cell的重用
- 你真的懂得tableview cell的两个重用方法嘛
- 一个tableView的Cell中有两个点击按钮及tableView的重用
- iOS tableView的cell的重用问题
- 解决TableView的Cell重用问题
- Java中8进制和16进制的表示方法
- HibernateTools实现pojo类 数据库schma mapping映射的相互转换 二
- 两图像相减
- Sort List
- Android多线程文件下载器
- tableview的两个取得重用cell方法的区别
- java中Comparator实现两个对象比较
- 修改WAMP默认的80端口
- 【leetcode】Substring with Concatenation of All Words
- 编程之美--只考加法的面试题1
- rac 介绍
- Lua和C语言的交互2【转】
- Lua和C语言的交互3【转】
- codeforces 133A HQ9+(字符串水题)