0

I feed a UITableView with a list of names and images from a JSON. "SDWebImage" handles images download. It works OK apart from the fact that the images move to the left when the user selects a row or when scrolls the table view.

Two screen captures to show the issue.

Initial aspect

After selection

Interface Builder setup IB

Implementation is pretty standard:

#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;
}

What can I do to stop images moving?

Tulon
  • 4,011
  • 6
  • 36
  • 56
Luis
  • 447
  • 1
  • 7
  • 24

1 Answers1

1

I've just had a similar issue on an app and found it was because I was re-using UITableViewCells default imageView IBOutlet.

After creating my a new IBOutlet, called something other than imageView, and hooking it up it resolved the issue.

th3hamburgler
  • 624
  • 2
  • 8
  • 23