I have a custom tableviewcell using Autolayout, design in xib file.
design:
CustomTableViewCell.h:
@property (weak, nonatomic) IBOutlet UIView *customView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *constraintRatio;
it's works fine in the tableview.
what I want to do is update CustomView's Ratio programmatically, before the tableviewcell display.
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
CustomTableViewCell *customCell = [self.mainTableView dequeueReusableCellWithIdentifier:@"customCell"];
customCell.constraintRatio.constant = 2;
[customCell setNeedsUpdateConstraints];
[customCell setNeedsLayout];
[customCell layoutIfNeeded];
return customCell;
}
but the cell's ratio remain 1 after that. what did i do wrong or what did i miss? thanks for any suggestion.