没有重复使用表格单元格的索引路径 [英] No index path for table cell being reused

查看:162
本文介绍了没有重复使用表格单元格的索引路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这开始发生了。任何想法:代码:

This started to happen out of the blue. Any ideas: Code:

CUSTOMCLASSNAME(我已经替换了实际的类名,因为它包含客户端的名称。)

CUSTOMCLASSNAME (I have replaced the actual class name as it contains the name of the client.)

初始化我的tableView:

Initialising my tableView:

[self.tableView registerClass:[CUSTOMCLASSNAME class] forCellReuseIdentifier:[self reuseIdentifier]];

在行的单元格中:

您好,标题正在控制台中打印。这是我的cellForRow:

Hi, the title is being printed in the console. This is my cellForRow:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    AVTCheckListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[self reuseIdentifier] forIndexPath:indexPath];

    [self configureCell:cell atIndexPath:indexPath];

    return cell;
}

- (void)configureCell:(AVTCheckListTableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath {
    ChecklistGroup *group = [self.checklistFetchedResultsController.fetchedObjects objectAtIndex:indexPath.section];

    ChecklistItem *item = [self getChecklistItemForIndexPath:indexPath];

    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    [[cell cellTextView] setAttributedText:[[item checked] boolValue] ? [[NSAttributedString alloc] initWithString:[item name] attributes:@{ NSStrikethroughStyleAttributeName : @(NSUnderlineStyleSingle) } ] : [[NSAttributedString alloc] initWithString:[item name]]];
    [[cell cellTextView] setUserInteractionEnabled:[[group isUserDefined] boolValue]];
    [[cell cellTextView] setTag:indexPath.row];
    [[cell cellTextView] setDelegate:self];
    [[cell tickImage] setHidden:![[item checked] boolValue]];
}

//Method that returns re-use:

- (NSString *) reuseIdentifier {
    return @"CheckListTableView";
}


推荐答案

我在几天。在我的自定义单元格中,我有一个textView,当我将它添加到contentView时,我正在这样做:

I worked this out after a few days. In my custom cell I had a textView, when I was adding it to the contentView I was doing this:

[self.cellTextView setClearsOnInsertion:YES];

这是问题的原因;如果其他人有类似的问题。

This was the cause of the issue; incase anyone else has a similar problem.

快乐编码: - )

这篇关于没有重复使用表格单元格的索引路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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