- (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'的更多相关文章

  1. reason: 'unable to dequeue a cell with identifier Cell

    今天在cell重用的时候出现一下错误 reason:  'unable  to  dequeue  a  cell  with  identifier  Cell  -  must  register ...

  2. unable to dequeue a cell with identifier MealTableViewCell

    1 问题描述 Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable ...

  3. 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 ...

  4. Vs打包工程 错误: Unable to update the dependencies of the project (转)

    Setup Project 错误: Unable to update the dependencies of the project 在VS2010中编译包含安装工程的解决方案提示错误:Unable ...

  5. file_get_contents()获取https出现这个错误Unable to find the wrapper “https” – did

    file_get_contents()获取https出现这个错误Unable to find the wrapper “https” – did 解决办法 ,如果你是用的服务器,可以参考这个办法,修改 ...

  6. IOS-static cell 与 dynamic cell 混合使用

    static cell 与 dynamic cell 混合使用 关于静态cell与动态cell的混合使用,google一下便会有很多相关文章,这里也是看过一些前辈的经验(已经忘记具体是从哪篇文章得到的 ...

  7. 实现点击cell实现改变cell和cell上控件的背景颜色

    话不多少,贴上代码吧!!! // // ViewController.m // CellChangeBgColorDemo // // Created by 思 彭 on 17/1/12. // Co ...

  8. iOS中UITableView数据源刷新了,但tableview当中的cell没有刷新

    你会不会遇到通过断点查看数据源模型的确刷新了,但是tableview没有刷新的情况,我遇到了,并通过下面的方法解决了,供大家参考! 在tableview中的数据源代理方法 p.p1 { margin: ...

  9. python安装大型包时出现错误Unable to find vcvarsall.bat

    在windows平台上,据说是安装cpython编写的包时会出现Unable to find vcvarsall.bat这种错误,缺失编译C的环境或组件吧,所以这个包就安装不成功,这个时候简单的方法就 ...

随机推荐

  1. 二级菜单jquery

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. Anagrams [LeetCode]

    Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be ...

  3. 2016年31款轻量高效的开源JavaScript插件和库

    目前有很多网站设计师和开发者喜欢使用由JavaScript开发的插件和库,但同时面临一个苦恼的问题:它们中的大多数实在是太累赘而且常常降低网站的性能.其实,其中也有不少轻量级的插件和库,它们不仅轻巧有 ...

  4. C语言实现进制转换

    #include<stdio.h> int main() {     char ku[16]={'0','1','2','3','4','5','6','7','8','9','A','B ...

  5. Java集合——List接口

    1.定义 List是Collection的子接口,元素有序并且可以重复,表示线性表. 2.方法 add(int index,Object e):在指定索引(和数组下标类似,为0,1,2....)放入元 ...

  6. ios基础篇(一)——UIView控件基本属性与常见用法

    1.frame 控件的位置和尺寸(以父控件的左上角为坐标原点(0,0)) 2.center 控件的中点(以父控件的左上角为坐标原点) 3.bounds 控件的位置和尺寸(以自己的左上角为坐标原点(0, ...

  7. Excel VBA记录

    -----------快捷键---------- 函数等提示(默认):ctrl+j 注释:上单引号' 设置单元格为空可以用:empty/null -----------基础语法--------- 基本 ...

  8. ACTIVITI 研究代码 之 模版模式

    模板方法模式需要开发抽象类和具体子类的设计师之间的协作.一个设计师负责给出一个算法的轮廓和骨架,另一些设计师则负责给出这个算法的各个逻辑步骤.代表这些具体逻辑步骤的方法称做基本方法(primitive ...

  9. Xwindow 连接 RHEL 5

    cd /etc/gdm/custom.conf ----------------------------------------- [security] AllowRemoteRoot=true [x ...

  10. 终于!Linaro 加盟 Zephyr 项目

    导读 为物联网构建实时操作系统的开源协作项目 Zephyr 项目宣布,Linaro 有限责任公司以白金会员的身份加盟该项目.Linaro是一家为 ARM 架构开发开源软件的协作工程组织,也是全球性机构 ...