Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS5中my UITableView中的dequeueReusableCellWithIdentifier错误_Ios_Ios5_Uitableview_Ios6 - Fatal编程技术网

iOS5中my UITableView中的dequeueReusableCellWithIdentifier错误

iOS5中my UITableView中的dequeueReusableCellWithIdentifier错误,ios,ios5,uitableview,ios6,Ios,Ios5,Uitableview,Ios6,我在iOS 5中遇到了这个错误 -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:]:发送到实例0xa217200的选择器无法识别 但是,我在iOS 6中没有发现错误。我如何解决这个问题?这是我的密码: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { sta

我在iOS 5中遇到了这个错误

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

但是,我在iOS 6中没有发现错误。我如何解决这个问题?这是我的密码:

- (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中新增的

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
但在iOS 5中,要创建
UITableViewCell
的实例,我们通常使用以下方法:-

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
在iOS 5中,不需要在iOS 6中使用的额外参数。(forindexath:)


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

以下是出现错误的原因。根据iOS 6.0文档集,UITableView类参考说明,iOS 2.0及更高版本中提供了
dequeueReusableCellWithIdentifier:
,iOS 6.0及更高版本中提供了
dequeueReusableCellWithIdentifier:forIndexPath:

需要将tableView委托方法粘贴到此处。请提供足够的代码以获取答案感谢Apple为UITableViewController创建默认模板代码,使用仅限iOS6的方法而不告诉我们!