UITableView错误 ‘unable to dequeue a cell with identifier Cell'
- (id)dequeueReusableCellWithIdentifier:(NSString *)identifier;
- (id)dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath
NS_AVAILABLE_IOS(6_0); // newer
1 第二个方法在SDK5.0是运行不起来的。
2 如果需要使用这个方法,你必须使用配套的方法来一起用,下面两个配套方法:

1 // Beginning in iOS 6, clients can register a nib or class for each cell.
2 // If all reuse identifiers are registered, use the newer -dequeueReusableCellWithIdentifier:forIndexPath: to guarantee that a cell instance is returned.
3 // Instances returned from the new dequeue method will also be properly sized when they are returned.
4 - (void)registerNib:(UINib *)nib forCellReuseIdentifier:(NSString *)identifier NS_AVAILABLE_IOS(5_0);
5 - (void)registerClass:(Class)cellClass forCellReuseIdentifier:(NSString *)identifier NS_AVAILABLE_IOS(6_0);

注意看上面的注释
3 比如你已经用NIB做了一个Cell,或者自定义了一个Cell。我们在你创建UITableView的时候,就可以顺带
1 self.tableView.backgroundColor = xxxx;
2 [self.tableView registerClass:[CustomCell class] forCellReuseIdentifier:@"CustomCell"];
这样你在
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
这个方法里,你就可以省下这些代码:

1 static NSString *CellIdentifier = @"Cell";
2 if (cell == nil) {
3 cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
4 //设置你的cell
5 }

而只需要
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
UITableView错误 ‘unable to dequeue a cell with identifier Cell'的更多相关文章
- reason: 'unable to dequeue a cell with identifier Cell
今天在cell重用的时候出现一下错误 reason: 'unable to dequeue a cell with identifier Cell - must register ...
- unable to dequeue a cell with identifier MealTableViewCell
1 问题描述 Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable ...
- swift写一个简单的列表unable to dequeue a cell with identifier reuseIdentifier - must register a nib or a cla
报错:unable to dequeue a cell with identifier reuseIdentifier - must register a nib or a class for the ...
- Vs打包工程 错误: Unable to update the dependencies of the project (转)
Setup Project 错误: Unable to update the dependencies of the project 在VS2010中编译包含安装工程的解决方案提示错误:Unable ...
- file_get_contents()获取https出现这个错误Unable to find the wrapper “https” – did
file_get_contents()获取https出现这个错误Unable to find the wrapper “https” – did 解决办法 ,如果你是用的服务器,可以参考这个办法,修改 ...
- IOS-static cell 与 dynamic cell 混合使用
static cell 与 dynamic cell 混合使用 关于静态cell与动态cell的混合使用,google一下便会有很多相关文章,这里也是看过一些前辈的经验(已经忘记具体是从哪篇文章得到的 ...
- 实现点击cell实现改变cell和cell上控件的背景颜色
话不多少,贴上代码吧!!! // // ViewController.m // CellChangeBgColorDemo // // Created by 思 彭 on 17/1/12. // Co ...
- iOS中UITableView数据源刷新了,但tableview当中的cell没有刷新
你会不会遇到通过断点查看数据源模型的确刷新了,但是tableview没有刷新的情况,我遇到了,并通过下面的方法解决了,供大家参考! 在tableview中的数据源代理方法 p.p1 { margin: ...
- python安装大型包时出现错误Unable to find vcvarsall.bat
在windows平台上,据说是安装cpython编写的包时会出现Unable to find vcvarsall.bat这种错误,缺失编译C的环境或组件吧,所以这个包就安装不成功,这个时候简单的方法就 ...
随机推荐
- js正则--验证6-12位至少包含数字、小写字母和大些字母中至少两种字符,
var reg=/^((([a-z])+([0-9])+)|(([0-9])+([a-z])+)|(([A-Z])+([0-9])+)|(([0-9])+([A-Z])+)|(([a-z])+([A- ...
- uploader上传
综述 Uploader是非常强大的异步文件上传组件,支持ajax.iframe.flash三套方案,实现浏览器的全兼容,调用非常简单,内置多套主题支持和常用插件,比如验证.图片预览.进度条等. 广泛应 ...
- valuestack,stackContext,ActionContext.之间的关系
者之间的关系如下图所示: relation ActionContext 一次Action调用都会创建一个ActionContext 调用:ActionContext context = ActionC ...
- css样式初始化
不同的浏览器对有些标签的默认显示是不同的,对css样式初始化可以实现样式的统一,消除不同浏览器间页面显示的差异性... 一般初始化方式为:*{margin:0:padding:0:}
- JavaScript中给对象添加函数的方式
1. function 类名(){ this.属性: } var 对象名=new 类名(): function 函数名(){ //执行代码 } 对象名.属性名=函数名: 对象名.属性名(): func ...
- Objective-C:Foundation框架-常用类-NSDate
直接上代码吧: #import <Foundation/Foundation.h> #pragma mark 日期创建 void dateCreate() { // date方法返回的就是 ...
- 转载:javascript面向对象编程:非构造函数的继承
一.什么是"非构造函数"的继承? 比如,现在有一个对象,叫做"中国人". var Chinese = { nation:'中国' }; 还有一个对象,叫做&qu ...
- 开发excel 自定义func
http://www.cnblogs.com/brooks-dotnet/archive/2011/01/16/1936871.html http://club.excelhome.net/threa ...
- java之进制转换
[转载]晨风�0�5�0�2�0�1�6�6 2014年03月08日 于 爱Java 发表 众所周知.程序世界计算机中采用的是二进制,一个数字可以用任意进制表示.所以看一个数据值的同时.还要观察它的进 ...
- POJ 3384
题目大意: 给定一个多边形,给定一个圆的半径,要求在多边形中放置两个同样半径的圆,可相互覆盖,但不能超出多边形的范围,希望两个圆的面积覆盖和最大 输出任意一组满足的圆的圆心点 如果两个圆不相互覆盖,那 ...