title: UITableView Sectionheader loaded from XIB sometimes gets displayed incorrectly
body: <p>I have created a custom XIB File with a UIView, which I wanted to be displayed in an <code>UITableView</code> as view for header in section. I properly implemented the required delegate methods, as of course:</p>
  
  <pre><code>- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:
    (NSInteger)section 
  {
      if (tableView == self.messageTableView) {
          TableViewHeaderView *header = [[[NSBundle mainBundle] 
          loadNibNamed:@"TableViewHeaderView" owner:self options:nil] lastObject];
  
          [header.titleLabel setText:@"A String"];
          [header.addressLabel setText:@"Another String"];
  
          [header sizeToFit]; //I tried it with and without this line, 
                              //  does not seem to help
          return header;
      }
      return nil;
  }
  </code></pre>
  
  <p>Thereby the <code>TableViewHeaderView</code> Class is a Subclass of <code>UIView</code>. </p>
  
  <p>Everything seemed to work quite well, I actually did use this approach in some other projects as well and everything seemed to work well. Nevertheless I encountered a quite strange and random error: Running the app and playing around with the data of the Tableview, some Sectionheader-Views sometimes get displayed incorrectly like in the following screen. Due to my new account in this forum I cannot paste the picture directly into this post. But you can use the link instead (sorry for that):</p>
  
  <p><a href="http://i.stack.imgur.com/JSeVz.png" rel="nofollow">http://i.stack.imgur.com/JSeVz.png</a></p>
  
  <p>The <code>UITableView</code> has eight sections in this example. As you can clearly see the sectionheader-views "Sending 3,4,5" are totally misplaced. They are stuck to their position and move along when scrolling the tableview. However, when you scroll down the tableview they will appear a second time in the correct place. </p>
  
  <p>By the way: I don't use AutoLayout in this project, the view has a correct height, corresponding to the <code>heightForHeaderInSection:</code> delegate method, and the same width as the underlying tableview itself. The Autosizing of the HeaderView as well as the underlying UITableView is set to:</p>
  
  <p><a href="http://i.stack.imgur.com/Ms0ZC.png" rel="nofollow">http://i.stack.imgur.com/Ms0ZC.png</a></p>
  
  <p>Reloading the tableview does not help either.</p>
  
  <p>Does anyone have an idea what's wrong there? I don't have the slightest clue. Or is this approach of using custom views kind of old-fashined?</p>
  
  <p>Thanks for your help!</p>