我向UITableView
提供了一个JSON名称和图片列表。 “SDWebImage”处理图像下载。除了当用户选择行或滚动表格视图时图像向左移动这一事实,它的工作正常。
两个屏幕截图显示问题。
Interface Builder设置
实施非常标准:
#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;
}
如何阻止图像移动?
答案 0 :(得分:1)
我在应用上遇到了类似的问题,发现这是因为我正在重新使用UITableViewCells默认的imageView IBOutlet。
在创建一个新的IBOutlet之后,调用了除imageView之外的其他东西,并将其挂起来解决了这个问题。