开发者

TTImageView in TTTableViewCell cell reuse issue

开发者 https://www.devze.com 2023-03-16 14:48 出处:网络
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.

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 all开发者_运维问答oc] init];
        [self.contentView addSubview:_main_title];

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

    }
    return self;
}


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

0

精彩评论

暂无评论...
验证码 换一张
取 消