I have table view cell like this.
After image is downloaded, I update the height of image view so that aspect ratio is correct (width is fixed).
[self.imgMain removeConstraint:self.aspectConstraint];
self.aspectConstraint = [NSLayoutConstraint constraintWithItem:self.imgMain
                                                     attribute:NSLayoutAttributeWidth
                                                     relatedBy:NSLayoutRelationEqual
                                                        toItem:self.imgMain
                                                     attribute:NSLayoutAttributeHeight
                                                    multiplier:aspectRatioMult
                                                      constant:0];
self.aspectConstraint.priority = 999;//the reason is that if it is 1000, it violate with my label height constraints and it broke label constraint.So I set to 999
[self.imgMain addConstraint:self.aspectConstraint];
[self setNeedsUpdateConstraints];
[self updateConstraints];
Problem is that although I update constraints, tableviewcell never change and it reuse cell in every 3 cell for the first time. If I scroll up and down, height is updated. How shall I update my constraints successfully?
Edit
I set cell data like this.
- (void)setData:(NSDictionary *)dict
{
    if (!dict)
        return;
    self.cellData = [NSDictionary dictionaryWithDictionary:dict];
    [self.imgMain setImageWithURL:[NSURL URLWithString:self.cellData[SERVER_IMG]] placeholderImage:[UIImage new] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL){
        if (image) {
            [self putImage:image];
            return ;
        }
        [self putImage:[UIImage imageNamed:@"placeholder.png"]];
    } usingActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    NSString *name = [NSString stringWithFormat:@"%@%@",SERVER_NAME, [LocalizationHelper getExtForLocale]];
    if([self.cellData[SERVER_INTEGRATION_ID]intValue]==SERVER_ISHOPCHANGI_ID) {
        [self.lblShopName setText:self.cellData[SERVER_DESCRIPTION]];
        [self.btnMap setHidden:YES];
        self.imgWidthMapBtnConstraint.constant = 0;
    } else {
        [self.lblShopName setText:self.cellData[SERVER_LOCATIONS][0][SERVER_SHOP]];
        [self.btnMap setHidden:[Helper isPointZero:dict[SERVER_LOCATIONS][0]]];
        self.imgWidthMapBtnConstraint.constant = 33;
    }
    [self.lblOfferTitle setText:self.cellData[name]];
}

 
     
     
     
    