小编use*_*509的帖子

我如何实现`prepareForReuse`?

我正在设置一个用sdwebimage下载的图像UITableViewCell.为了,为了保持UITableView从显示错误的图像,我需要将图像设置为nilprepareForReuse.但是,我在实现这个方面遇到了一些麻烦.

这是我设置图像的地方:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString * reuseIdentifier = @"programmaticCell";
    MGSwipeTableCell * cell = [self.tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    if (!cell) {
        cell = [[MGSwipeTableCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuseIdentifier];
    }

    CGFloat brightness = [UIScreen mainScreen].brightness;

    cell.textLabel.text = [self.streams[indexPath.row] name];
    cell.detailTextLabel.text = [self.streams[indexPath.row] published];

    NSString *imageUrl = [NSString stringWithFormat: @"%@", [self.streams[indexPath.row] photo]];

    NSLog(@"Image is: %@ and path is: %d", imageUrl, indexPath.row);

    [cell.imageView sd_setImageWithURL:[NSURL URLWithString:imageUrl]
                      placeholderImage:[UIImage imageNamed:@"tile-blue.png"] options:indexPath.row == 0 ? SDWebImageRefreshCached : …
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview ios

7
推荐指数
1
解决办法
7459
查看次数

标签 统计

ios ×1

objective-c ×1

uitableview ×1