This problem has had me stuck for a while now and I can't for the life of me see why it is occurring.
I have a tableView with custom cells inside it. The cell has an imageView top left and then various information which is looked up from a plist. I am using auto-layout which sets the position of all the elements. I have refreshed all the constraints so they are all updated. See below:
The problem occurs when I scroll the view down and the cell goes out of screen. I am dequeing them so each time they will be refreshed.
BSettingsCell * cell = [tableView_ dequeueReusableCellWithIdentifier:bSettingsCellIdentifier];
When they do refresh though the constraints they were bound by now don't work. The imageview is 60x60 pixels and the image is 120x120 pixels and named fruitMainImage@2x.png to take retina screens into account.
I have put a red border around the picture to make it easier to see what is happening. As you can see the image is moving down for some reason once refreshed.
I have tried switching to frame layout to fix it in position and this doesn't work.
I found this stackoverflow question which seems to raise the same issue but only raises it as an issue instead of helping get round the issue in anyway.
Any help would be greatly appreciated as I don't fancy rewriting all my code with keeplayout if there is an easy way to fix it.
EDIT:
Here is my cellForRowAtIndex method:
- (UITableViewCell *)tableView:(UITableView *)tableView_ cellForRowAtIndexPath:(NSIndexPath *)indexPath {
BSettingsCell * cell = [tableView_ dequeueReusableCellWithIdentifier:bSettingsCellIdentifier];
NSDictionary * dict = [_settingsData objectForKey:_settingsPacks[indexPath.row]];
cell.nameLabel.text = [dict objectForKey:bSettingsName];
cell.byLabel.text = [dict objectForKey:bArtist];
cell.stickerImageView.image = [UIImage imageNamed:[dict objectForKey:bImage]];
// To make it obvious that the view is changing position
cell.stickerImageView.layer.borderColor = [UIColor redColor].CGColor;
cell.stickerImageView.layer.borderWidth = 2;
cell.descriptionView.text = [dict objectForKey:bDescription];
[cell.linkButton setTitle: [dict objectForKey:bLink] forState: UIControlStateNormal];
cell.linkButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
and also a shot of the auto layout constraints in the XIB file: (Note although not included in the screen shots the name and by label are keeping with the constraints fine)