Q:

Setting UITableViewCell's layout programmatically using anchors

I am trying to create a custom UITableViewCell using auto layout's anchors. The cell should:

Have two columns
Have three rows
The content of the "cells" should just be UILabel
Should have height set dynamically based on height of its rows

However, layout anchors for UIViewCell seem to work differently than for UIView and I am now getting the results I want, I guess this could be due to UITableView's complex view hierarchy (content view, accessory view,...).

Am I doing some obvious mistake here? Would wrapping the UILabel into UIView or UIStackView solve the issue?
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {

        UILabel *col1row1 = [UILabel new];
        UILabel *col1row2 = [UILabel new];
        UILabel *col1row3 = [UILabel new];
        UILabel *col2row1 = [UILabel new];
        UILabel *col2row2 = [UILabel new];
        UILabel *col2row3 = [UILabel new];

        [self setTranslatesAutoresizingMaskIntoConstraints:NO];
        [self.contentView setTranslatesAutoresizingMaskIntoConstraints:NO];
        [col1row1 setTranslatesAutoresizingMaskIntoConstraints:NO];
        [col1row2 setTranslatesAutoresizingMaskIntoConstraints:NO];
        [col1row3 setTranslatesAutoresizingMaskIntoConstraints:NO];
        [col2row1 setTranslatesAutoresizingMaskIntoConstraints:NO];
        [col2row2 setTranslatesAutoresizingMaskIntoConstraints:NO];
        [col2row3 setTranslatesAutoresizingMaskIntoConstraints:NO];

        self.col1row1 = col1row1;
        self.col1row2 = col1row2;
        self.col1row3 = col1row3;
        self.col2row1 = col2row1;
        self.col2row2 = col2row2;
        self.col2row3 = col2row3;

        [self.contentView addSubview:col1row1];
        [self.contentView addSubview:col1row2];
        [self.contentView addSubview:col1row3];
        [self.contentView addSubview:col2row1];
        [self.contentView addSubview:col2row2];
        [self.contentView addSubview:col2row3];

        [col1row1 setTextAlignment:NSTextAlignmentLeft];
        [col1row2 setTextAlignment:NSTextAlignmentLeft];
        [col1row3 setTextAlignment:NSTextAlignmentLeft];
        [col2row1 setTextAlignment:NSTextAlignmentRight];
        [col2row2 setTextAlignment:NSTextAlignmentRight];
        [col2row3 setTextAlignment:NSTextAlignmentRight];

        [col1row1 setBackgroundColor:[UIColor yellowColor]];
        [col1row2 setBackgroundColor:[UIColor yellowColor]];
        [col1row3 setBackgroundColor:[UIColor yellowColor]];
        [col2row1 setBackgroundColor:[UIColor yellowColor]];
        [col2row2 setBackgroundColor:[UIColor yellowColor]];
        [col2row3 setBackgroundColor:[UIColor yellowColor]];

        [self.widthAnchor constraintEqualToAnchor:self.superview.widthAnchor multiplier:1.0].active = YES;
        [self.contentView.widthAnchor constraintEqualToAnchor:self.superview.widthAnchor multiplier:1.0].active = YES;

        [col1row1.leftAnchor constraintEqualToAnchor:self.contentView.leftAnchor constant:1.0].active = YES;
        [col1row2.leftAnchor constraintEqualToAnchor:self.contentView.leftAnchor constant:1.0].active = YES;
        [col1row3.leftAnchor constraintEqualToAnchor:self.contentView.leftAnchor constant:1.0].active = YES;
        [col2row1.rightAnchor constraintEqualToAnchor:self.contentView.rightAnchor constant:1.0].active = YES;
        [col2row2.rightAnchor constraintEqualToAnchor:self.contentView.rightAnchor constant:1.0].active = YES;
        [col2row3.rightAnchor constraintEqualToAnchor:self.contentView.rightAnchor constant:1.0].active = YES;

        [col1row1.topAnchor constraintEqualToAnchor:self.contentView.topAnchor constant:1.0].active = YES;
        [col1row2.topAnchor constraintEqualToAnchor:col1row1.bottomAnchor constant:1.0].active = YES;
        [col1row3.topAnchor constraintEqualToAnchor:col1row2.bottomAnchor constant:1.0].active = YES;
        [col2row1.topAnchor constraintEqualToAnchor:self.contentView.topAnchor constant:1.0].active = YES;
        [col2row2.topAnchor constraintEqualToAnchor:col2row1.bottomAnchor constant:1.0].active = YES;
        [col2row3.topAnchor constraintEqualToAnchor:col2row2.bottomAnchor constant:1.0].active = YES;

        [self.bottomAnchor constraintEqualToAnchor:col1row3.bottomAnchor constant:1.0].active = YES;
        [self.contentView.bottomAnchor constraintEqualToAnchor:col1row3.bottomAnchor constant:1.0].active = YES;

        [self.contentView setBackgroundColor:[UIColor greenColor]];

    }
    return self;
}

After removing the lines @Mahendra GP suggested
[self setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.contentView setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.widthAnchor constraintEqualToAnchor:self.superview.widthAnchor multiplier:1.0].active = YES;
[self.contentView.widthAnchor constraintEqualToAnchor:self.superview.widthAnchor multiplier:1.0].active = YES;

...the result looks better, but the column 2 is not visible in the view hierarchy:

A:

For the table view cell you don't need to set following... 
[self setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.contentView setTranslatesAutoresizingMaskIntoConstraints:NO];

It is only required to set on views that is going to be added.
widthAnchor is also not requited for the cell as tableview cell will be of width as table view has. so remove these lines...
[self.widthAnchor constraintEqualToAnchor:self.superview.widthAnchor multiplier:1.0].active = YES;
[self.contentView.widthAnchor constraintEqualToAnchor:self.superview.widthAnchor multiplier:1.0].active = YES;

EDIT:
Change the rightAnchor constraints of column 2 as follow...
[self.contentView.rightAnchor constraintEqualToAnchor:col2row1.rightAnchor constant:1.0].active = YES;
[self.contentView.rightAnchor constraintEqualToAnchor:col2row2.rightAnchor constant:1.0].active = YES;
[self.contentView.rightAnchor constraintEqualToAnchor:col2row3.rightAnchor constant:1.0].active = YES;

