选择单元格或滚动时UITableView上的UIImage移动

时间:2014-05-21 11:38:55

标签: ios uitableview uiimage sdwebimage

我向UITableView提供了一个JSON名称和图片列表。 “SDWebImage”处理图像下载。除了当用户选择行或滚动表格视图时图像向左移动这一事实,它的工作正常。

两个屏幕截图显示问题。

Initial aspect

After selection

Interface Builder设置 IB

实施非常标准:

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return array.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell  = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
    if (cell == nil ) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"Cell"];

    }
    cell.textLabel.text = [[array objectAtIndex:indexPath.row]objectForKey:@"marca"];
    cell.textLabel.lineBreakMode = NSLineBreakByWordWrapping;

    [cell.imageView setImageWithURL:[NSURL URLWithString:[[array objectAtIndex:indexPath.row]objectForKey:@"photoUrl"]]placeholderImage:[UIImage imageNamed:@"placeholder.png"] ];
    return cell;
}

如何阻止图像移动?

1 个答案:

答案 0 :(得分:1)

我在应用上遇到了类似的问题,发现这是因为我正在重新使用UITableViewCells默认的imageView IBOutlet。

在创建一个新的IBOutlet之后,调用了除imageView之外的其他东西,并将其挂起来解决了这个问题。

相关问题