iOS5 中我的 UITableView 中的 dequeueReusableCellWithIdentifier 错误

dequeueReusableCellWithIdentifier error in my UITableView in iOS5(iOS5 中我的 UITableView 中的 dequeueReusableCellWithIdentifier 错误)
本文介绍了iOS5 中我的 UITableView 中的 dequeueReusableCellWithIdentifier 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我在 iOS 5 中遇到此错误

I am getting this error in iOS 5

-[UITableView dequeueReusableCellWithIdentifier:forIndexPath:]:无法识别的选择器发送到实例0xa217200

但是,我在 iOS 6 中没有遇到任何错误.我该如何解决这个问题?这是我的代码:

However, I get no errors in iOS 6. How can I fix this problem? Here's my code:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"MyCell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; /// SIGABRT error

    if (!cell)
    {
        cell = [[UITableViewCell alloc]
        initWithStyle: UITableViewCellStyleSubtitle
        reuseIdentifier: CellIdentifier];
    }

    return cell;
}

推荐答案

EDIT:这个方法是iOS6+ SDK新增的.

EDIT: This method is newly added in iOS6+ SDK.

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

但在 iOS 5 中,创建 UITableViewCell 的实例我们通常使用这种方法:-

But in iOS 5, to create instance of UITableViewCell we generally use this method :-

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

在 iOS 5 中,不需要你在 iOS 6 中使用的额外参数.(forIndexPath:).

In iOS 5, there is no need of extra parameter which you have used in iOS 6. (forIndexPath:).

所以改变你的方法.它会起作用的.

So change your method. It will work.

这篇关于iOS5 中我的 UITableView 中的 dequeueReusableCellWithIdentifier 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)
Resume game cocos2d(恢复游戏 cocos2d)
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)
[ios.cocos2d+box2d]how to disable auto-rotation?([ios.cocos2d+box2d]如何禁用自动旋转?)
Storing and reading files from Documents directory iOS 5(从 Documents 目录存储和读取文件 iOS 5)
How can I implement a virtual joystick for a cocos2d game outside the cocos2d environment?(如何在 cocos2d 环境之外实现 cocos2d 游戏的虚拟摇杆?)