- (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. EasyDropDown – 很棒的下拉菜单 含精美主题

    EasyDropDown 是一个 jQuery 插件,你可以毫不费力地将简陋的 Select 元素设置为可定制风格的下拉菜单,用于表单或者一般的导航.和著名的下拉插件 Chosen 很像,但是具有自己 ...

  2. 为MySQL选择合适的备份方式

    数据库的备份是极其重要的事情.如果没有备份,遇到下列情况就会抓狂: UPDATE or DELETE whitout where… table was DROPPed accidentally… IN ...

  3. saiku-添加数据源以及保证数据源的一致性

    采用任何一种添加数据源的方式都不能保证数据源的一致和完整,所以需要两种结合来管理数据源 1.通过saiku的管理台添加数据源 ① 第一种方式:schema和ds都在管理台添加 1)上传schema文件 ...

  4. 笔记6:winfrom连接sql server 进行数据交换

    今天的作业是用winfrom窗体做一个留言板,如图: 要求和数据库有查询和添加功能.下拉框里的值是直接获取数据库中的值 一.连接数据库,获取表中数据 //创建一个存数据的表 DataTable tab ...

  5. hdu 4315 Climbing the Hill(阶梯博弈转nim博弈)

    Climbing the Hill Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  6. 用XmlSerializer进行xml反序列化的时候,程序报错: 不应有 <xml xmlns=''>

    原因 一,类型错误: 比如xml本来是UserInfo类型 用XmlSerializer进行反序列化传入的类型是MemberInfo这就会报错 二,xml根节点和对象的类名不一致,而又没有对类加入[X ...

  7. 百度地图API:利用瓦片生成工具,自定义背景图片

    参考酸奶小妹的博文<[百度地图API]如何制作一张魔兽地图!!——CS地图也可以,哈哈哈> (http://www.cnblogs.com/milkmap/archive/2011/05/ ...

  8. 聚类算法:K-means 算法(k均值算法)

    k-means算法:      第一步:选$K$个初始聚类中心,$z_1(1),z_2(1),\cdots,z_k(1)$,其中括号内的序号为寻找聚类中心的迭代运算的次序号. 聚类中心的向量值可任意设 ...

  9. 分支语句switch case

    Switch case必须与break一起使用 Break 是跳转语句.与switch case连用的时候是跳出最近的{}. static void Main(string[]args ) { //s ...

  10. [工作技能]SVN

    有的时候SVN上传txt文本文件,会报是bin文件的错误,解决方式是在.subversion文件夹下的config文件中加这么一句 *.txt = svn:mime-type=text/plain;s ...