title: Failed to set label frame in tableView:cellForRowAtIndexPath: method
body: <p>The frame of the label in <code>tableViewCell</code> can not be set in the <code>ableView:cellForRowAtIndexPath:</code> method. In fact as show in the <code>NSLog</code>, the label's frame has changed but it did not show on the view.  <strong>I expected the label(with green background) should be taller than in the picture, which can show all the text in it</strong>. The <code>Prototype Cell</code> with <code>Identifier</code> "cell" is created in the <code>storyboard</code>. Any help will be appreciated.</p>
  
  <p>ps: Xcode 5.0.2, iOS7</p>
  
  <pre><code>- (void)viewDidLoad
  {
      [super viewDidLoad];
      NSString * str = @"Do any additional setup after loading the view, typically from a nib Do any additional setup after loading the view, typically from a nib Do any additional setup after loading the view, typically from a nib";
      NSArray *array = [NSArray arrayWithObjects:str, str, str , str, str, str, nil];
  }
  
  -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
      NSInteger row = indexPath.row;
      CGSize sizeConstraint = CGSizeMake(tableView.frame.size.width, 2000);
      CGSize size = [[array objectAtIndex:row] boundingRectWithSize:sizeConstraint options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: [UIFont fontWithName:FontName size:FontSize]} context:nil].size;
  
      return size.height + 20;
  }
  
  
  -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
      NSInteger row = indexPath.row;
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
      UILabel *label = (UILabel *)[cell.contentView viewWithTag:1];
      label.autoresizingMask = UIViewAutoresizingNone;
      label.numberOfLines = 0;
      label.lineBreakMode = NSLineBreakByWordWrapping;
      label.font = [UIFont fontWithName:FontName size:FontSize];
      label.backgroundColor = [UIColor greenColor];
      label.text = [array objectAtIndex:row];
  
      CGSize sizeConstraint = CGSizeMake(tableView.frame.size.width, 2000);
      CGSize size = [label.text boundingRectWithSize:sizeConstraint options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: label.font} context:nil].size;
      CGRect rect = label.frame;
      rect.size.height = size.height;
      [label setFrame:rect];
      NSLog(@"label height :%f", label.frame.size.height);
      [label sizeThatFits:sizeConstraint];
      return cell;
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/FeooT.png" alt="enter image description here">
  <img src="https://i.stack.imgur.com/oQhtS.png" alt="enter image description here"></p>
  
  <p>when you scroll the <code>tableView</code>, you can see the label in the first and second cell are well displayed now. (Here i just scrolled out the two cells and pull them back.)</p>
  
  <p><img src="https://i.stack.imgur.com/6nEN5.png" alt="after scroll the tableView"></p>