title: Objective C setup auto row height in code
body: <p>I'm working with an old Objective-C project which has not any storyboard. I need a <code>UITableView</code> to display the result with <code>UITableViewCell</code> that contains 3 labels. The task is to align 3 labels vertically in the <code>UITableviewCell</code> </p>
  
  <p>Here is my Label initiation:</p>
  
  <pre><code>serviceTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 10, 200, LONG_MAX)];
  [serviceTitleLabel setFont:[UIFont SingPostRegularFontOfSize:16.0f fontKey:kSingPostFontOpenSans]];
  [serviceTitleLabel setNumberOfLines:0];
  [serviceTitleLabel setTextColor:RGB(51, 51, 51)];
  [serviceTitleLabel setBackgroundColor:[UIColor clearColor]];
  [serviceTitleLabel setTextAlignment:NSTextAlignmentLeft];
  [contentView addSubview:serviceTitleLabel];
  
  statusLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 30, 200, 30)];
  [statusLabel setFont:[UIFont SingPostBoldFontOfSize:12.0f fontKey:kSingPostFontOpenSans]];
  [statusLabel setTextColor:RGB(125, 136, 149)];
  [statusLabel setBackgroundColor:[UIColor clearColor]];
  [contentView addSubview:statusLabel];
  
  costLabel = [[UILabel alloc] initWithFrame:CGRectMake(216, 20, 85, 30)];
  costLabel.right = contentView.right - 15;
  [costLabel setFont:[UIFont SingPostBoldFontOfSize:16.0f fontKey:kSingPostFontOpenSans]];
  [costLabel setTextColor:RGB(51, 51, 51)];
  [costLabel setTextAlignment:NSTextAlignmentRight];
  [costLabel setBackgroundColor:[UIColor clearColor]];
  [contentView addSubview:costLabel];
  </code></pre>
  
  <p>How can we adjust in <code>UITableViewController</code> so that the size will resize according to the label size? Need to set up in both cell and tableview? Any help is much appreciated. Thanks.</p>
  
  <p>This is the screen now. Look not right</p>
  
  <p><a href="https://i.stack.imgur.com/7DiGE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7DiGE.png" alt="enter image description here"></a></p>