title: iOS - Dynamic heights on labels in tableViewCell
body: <p><strong>Edit: this is different from the duplicate because I have two variable-height labels, not one</strong></p>
  
  <p>I'm trying to do what I thought would be very simple. I have a table cell that has two labels in it. Each of those labels is loaded in via a dynamic data source and they could be of any length. I need the the labels to grow and shrink according to the data that's inside of them. This is turning out to be quite a challenge. </p>
  
  <p>I have created a new project that is absolutely bare boned in hopes of getting to the root of the problem.</p>
  
  <p><a href="http://i.stack.imgur.com/AGB8u.png" rel="nofollow">Scenario 1</a></p>
  
  <p><a href="http://i.stack.imgur.com/8dqdl.png" rel="nofollow">Scenario 2</a></p>
  
  <p>Both of my labels are set to 0 lines and line breaks: Word Wrap</p>
  
  <p>Any help is great appreciated.</p>
  
  <p>And the code that I currently have:</p>
  
  <pre><code>    - (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
          return 5;
      }
  
      - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
          return [self.tableView dequeueReusableCellWithIdentifier:@"myCell" forIndexPath:indexPath];
      }
  
      - (CGFloat) tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
          return 100;
      }
      - (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
      return UITableViewAutomaticDimension;
  }
  </code></pre>
  
  <p><strong>Solution found:</strong></p>
  
  <p>I added the following line of code before returning the cell, and everything magically worked.</p>
  
  <pre><code>[cell updateConstraintsIfNeeded];
  </code></pre>