title: UITableViewHeaderFooterView drawing incorrectly
body: <p>I have a table view with the usual stuff plugged in, the issue is in UITableViewHeaderFooterView, when they appear first they have unusual frame. But if i scroll down and back up(once they are reused) they appear fine. Here is the relevant code.</p>
  
  <p>EDIT: The table view cells on the other hand appear fine.</p>
  
  <p>The log for headerView at this line
  FAQSectionHeaderView *headerView = [self.tableView dequeueReusableHeaderFooterViewWithIdentifier:@"HeaderView"];
  shows this: </p>
  
  <pre><code>2013-11-01 15:16:04.716 FAQDetail[27576:70b] header View &lt;FAQSectionHeaderView: 0x8b582e0; baseClass = UITableViewHeaderFooterView; frame = (0 0; 0 0); text = ''; layer = &lt;CALayer: 0x8b58420&gt;&gt; at Section 0
  2013-11-01 15:16:04.718 FAQDetail[27576:70b] header View &lt;FAQSectionHeaderView: 0xa83edc0; baseClass = UITableViewHeaderFooterView; frame = (0 0; 0 0); text = ''; layer = &lt;CALayer: 0xa83ee80&gt;&gt; at Section 1
  2013-11-01 15:16:04.719 FAQDetail[27576:70b] header View &lt;FAQSectionHeaderView: 0x8c2f8e0; baseClass = UITableViewHeaderFooterView; frame = (0 0; 0 0); text = ''; layer = &lt;CALayer: 0x8c2c370&gt;&gt; at Section 2
  2013-11-01 15:16:04.719 FAQDetail[27576:70b] header View &lt;FAQSectionHeaderView: 0x8a3f7a0; baseClass = UITableViewHeaderFooterView; frame = (0 0; 0 0); text = ''; layer = &lt;CALayer: 0x8a3f860&gt;&gt; at Section 3
  2013-11-01 15:16:04.720 FAQDetail[27576:70b] header View &lt;FAQSectionHeaderView: 0x8c70dc0; baseClass = UITableViewHeaderFooterView; frame = (0 0; 0 0); text = ''; layer = &lt;CALayer: 0x8c6f0b0&gt;&gt; at Section 4
  </code></pre>
  
  <p>in ViewController.m</p>
  
  <pre><code>- (void)viewDidLoad
  {
  [super viewDidLoad];
  [self.tableView registerClass:[FAQSectionHeaderView class] forHeaderFooterViewReuseIdentifier:@"HeaderView"];
  [self.tableView registerClass:[FAQDetailCell class] forCellReuseIdentifier:@"Cell"];
  }
  - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
  
  FAQSectionHeaderView *headerView = [self.tableView dequeueReusableHeaderFooterViewWithIdentifier:@"HeaderView"];
  
  [headerView setupWithQuestion:[self.sectionTitleArray objectAtIndex:section]];
  
  return headerView;
  
  }
  
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath      *)indexPath
  {
  if (self.selectedSection == indexPath.section) {
  
  FAQDetailCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"Cell"];
  
  [cell initWithAnswer:[self.rowsTitleArray objectAtIndex:indexPath.section]];
  
  return cell;
  } else
      return nil;
  
  }
  </code></pre>
  
  <p>in FAQSectionHeaderView.m (subclass of UITableViewHeaderFooterView)</p>
  
  <pre><code>-(void)setupWithQuestion: (NSString *)question{
  [self.questionLabel removeFromSuperview];
  
  CGSize expectedLabelHeight = [FAQSectionHeaderView sizeForQuestion:question];
  
  self.questionLabel = [[UILabel alloc] init];
  
  self.questionLabel.frame = CGRectMake(10, 10, self.frame.size.width-20, expectedLabelHeight.height);
  
  NSMutableAttributedString *q = [[NSMutableAttributedString alloc] initWithString:[@"Q " stringByAppendingString:question]];
  
  [q addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 2)];
  
  [q addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, question.length)];
  
  
  [q addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:17] range:NSMakeRange(0, 2)];
  
  [self.questionLabel setAttributedText:q];
  
  self.questionLabel.font = [UIFont systemFontOfSize:17];
  
  self.questionLabel.numberOfLines = 0;
  [self addSubview:self.questionLabel];
  
  
  self.frame = CGRectMake(0, 0, self.frame.size.width, self.questionLabel.frame.size.height+20);
  
  }
  
  -(void)prepareForReuse{
  
  [self.questionLabel removeFromSuperview];
  
  }
  </code></pre>
  
  <p>Here is how it appears initially and after cell reuse kicks in.
  <img src="https://i.stack.imgur.com/PuWwr.png" alt="enter image description here"> <img src="https://i.stack.imgur.com/Fh5tp.png" alt="enter image description here"></p>