在iOS5中的UITableView中出现dequeueReusableCellWithIdentifier错误 [英] dequeueReusableCellWithIdentifier error in my UITableView in iOS5

查看:125
本文介绍了在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;
}


推荐答案

编辑:此方法是在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错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆