TTTableViewCell 中的 TTImageView 单元格重用问题

发布于 2024-11-17 20:47:22 字数 689 浏览 2 评论 0原文

让我描述一下我使用视频链接时遇到的问题此处

问题在于 TTImageView,它是左边的头像缺少一些图像。 我相信这是因为细胞重复利用?我该如何解决这个问题? 这是我的代码:

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)identifier {
    if (self == [super initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:identifier]) {
        _avatar = [[TTImageView alloc] init];
        [self.contentView addSubview:_avatar];

        _main_title = [[TTStyledTextLabel alloc] init];
        [self.contentView addSubview:_main_title];

        _detailed = [[UILabel alloc] init];
        [self.contentView addSubview:_detailed];

    }
    return self;
}

Let me describe the issue that I am having using a video link here

The issue is that the TTImageView, which is the avatar on the left is missing some image.
I believe this is because of cell reuse? How do I fix this?
Here is my code:

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)identifier {
    if (self == [super initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:identifier]) {
        _avatar = [[TTImageView alloc] init];
        [self.contentView addSubview:_avatar];

        _main_title = [[TTStyledTextLabel alloc] init];
        [self.contentView addSubview:_main_title];

        _detailed = [[UILabel alloc] init];
        [self.contentView addSubview:_detailed];

    }
    return self;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

缺⑴份安定 2024-11-24 20:47:22

Three20 在表格单元格中的prepareForReuse 函数方面存在一些问题。例如,请参阅 https://github.com/facebook/third20/issues/497

您现在可以做什么,创建您自己的表项单元格子类并具有prepareForReuse 函数。

///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)prepareForReuse {
  [super prepareForReuse];

  [_imageView2 unsetImage];
}

我实际上发现使用自己的 TTImageView 更容易,而不是使用现有的 _imageView TTImageView

Three20 has some issues with prepareForReuse function in the table cells. see https://github.com/facebook/three20/issues/497 for example.

What you can do now, to create a table item cell subclass of your own and have a prepareForReuse function.

///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)prepareForReuse {
  [super prepareForReuse];

  [_imageView2 unsetImage];
}

I actually found that it's easier to use my own TTImageView, and not to use the existing _imageView TTImageView

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文