title: UITableViewCell systemLayoutSizeFittingSize: returning 0 on iOS 7
body: <p>I have a UITableViewCell with a UIImage fixed at the left top corner, and a label at its right:</p>
  
  <pre><code>    -(UITableViewCell*) adCellFromTableView:(UITableView*)tableView
  {
      //Build the text
      NSString* adText = NSLocalizedString(@"MyFamily_fremiumAd", nil);
      NSMutableAttributedString* attrString = [[NSMutableAttributedString alloc] initWithString:adText];
  
      NSUInteger newLineLocation = [adText rangeOfCharacterFromSet:[NSCharacterSet newlineCharacterSet]].location;
  
      //Set the first line in orange
      NSDictionary* firstLineAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:15],
                                            NSForegroundColorAttributeName:ORANGE};
      [attrString addAttributes:firstLineAttributes range:NSMakeRange(0, newLineLocation)];
      //Set other lines in white
      NSDictionary* otherLinesAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:11],
                                             NSForegroundColorAttributeName:[UIColor whiteColor]};
      [attrString addAttributes:otherLinesAttributes range:NSMakeRange(newLineLocation, adText.length - newLineLocation)];
  
      //Get the cell
      if (!adCell)
      {
          adCell = [tableUsers dequeueReusableCellWithIdentifier:@"fremiumAd"];
      }
  
      //Set the text
      UILabel* label = (UILabel*)[adCell viewWithTag:1];
      label.attributedText = attrString;
  
      //Hide the separator
      adCell.separatorInset = UIEdgeInsetsMake(0, adCell.bounds.size.width, 0, 0);
  
      return adCell;
  }
  
  
  -(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  {
  UITableViewCell* cell = [self adCellFromTableView:tableView];
  
              //Make sure the cell's bounds are the same as tableview's before calculating the height
              //This is important when we calculate height after a UI rotation.
              cell.bounds = CGRectMake(0, 0, tableView.bounds.size.width, 0);
              NSLog(@"cell.bounds: %@",NSStringFromCGRect(cell.bounds));
              [cell setNeedsLayout];
              [cell layoutIfNeeded];
  
              CGSize fittingSize = [cell systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
              NSLog(@"fittingSize: %@",NSStringFromCGSize(fittingSize));
              return fittingSize.height;
  }
  </code></pre>
  
  <p>When I run the app on iOS 7.1 simulator, systemLayoutSizeFittingSize always return 0:</p>
  
  <blockquote>
    <p>cell.bounds: {{0, 0}, {320, 0}} </p>
    
    <p>fittingSize: {0,0}</p>
  </blockquote>
  
  <p>When I run the app on iOS 8.1 simulator, systemLayoutSizeFittingSize return a correct value:</p>
  
  <blockquote>
    <p>cell.bounds: {{0, 0}, {320, 0}}</p>
    
    <p>fittingSize: {320, 154.5}</p>
  </blockquote>
  
  <p>What am I missing?</p>
  
  <p><strong>Edit:</strong>
  I kinda fixed the problem using <code>[cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];</code> instead of <code>[cell systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];</code></p>
  
  <p>But this is just an half fix: when I rotate while the cell is visible, the size calculation is OK. But when I scroll the cell out of the screen, rotate the UI and then scroll back to the cell, the height calculation is wrong again in iOS 7.1</p>
  
  <p>Here are logs before rotating from landscape to portrait: </p>
  
  <blockquote>
    <p>tableView bounds: {{0, 0}, {569, 227}} </p>
    
    <p>cell.bounds : {{0, 0}, {569,0}} </p>
    
    <p>cell.contentView: {{0, 0}, {569, 0}} </p>
    
    <p>fittingSize: {559, 162}</p>
  </blockquote>
  
  <p>Here are logs after rotating from landscape to portrait: </p>
  
  <blockquote>
    <p>tableView bounds: {{0, 249}, {321, 463}} </p>
    
    <p>cell.bounds : {{0, 0}, {321,0}} </p>
    
    <p>cell.contentView: {{0, 0}, {321, 0}} </p>
    
    <p>fittingSize: {559, 162}</p>
  </blockquote>
  
  <p>As you can see, the size calculation is the same, no matter what the cell/cell.contentView width is.</p>
  
  <p>This result in a oversized cell when rotating from portrait to landscape, and an undersized cell when rotating from landscape to portrait.</p>