Initially, I have a UITableView that takes up only a small part of the screen using AutoLayout restrictions. UITableViewCells are laid out beautifully - they are very simple with only an orange left aligned label and a black right aligned label.
Now, if I scroll through the UITableView, it animates (AutoLayout restrictions) to occupy most of the screen, reloading the table and bringing additional UITableViewCells to the scene.
My problem is that the layout of the new UITableViewCells is animated along with the resizing of the UITableView. The black right mark appears immediately after the orange mark and is animated to the right. In the end, everything is aligned as expected, only I can not understand why the black right labels are not just located on the right, as soon as the cell appears on the screen, but instead is animated to the desired position.
Is there a way to tell the UITableViewCell to correctly position its contents relative to the width of the UITableView and the specified AutoLayout restrictions and thus bypass the animation of the contents of the UITableViewCell?
My code for creating a UITableViewCell is as follows:
- (instancetype)init
{
self = [super init];
if (self) {
self.textLabel = [[UILabel alloc]init];
self.textLabel.translatesAutoresizingMaskIntoConstraints = NO;
self.textLabel.font = [UIFont boldSystemFontOfSize:16.0];
self.textLabel.textColor = [UIColor orangeColor];
[self.contentView addSubview:self.textLabel];
self.amountLabel = [[UILabel alloc]init];
self.amountLabel.translatesAutoresizingMaskIntoConstraints = NO;
self.amountLabel.textAlignment = NSTextAlignmentRight;
self.amountLabel.font = [UIFont boldSystemFontOfSize:16.0];
[self.contentView addSubview:self.amountLabel];
NSDictionary *views = @{@"textLabel": self.textLabel, @"amountLabel": self.amountLabel};
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|-10-[textLabel]-10-[amountLabel]-10-|" options:0 metrics:nil views:views]];
}
return self;
}
Initial TableView before animation:

TableView during animation (with black right mark in the middle of the path to the right):
