title: iOS - UITableView not scrolling to bottom
body: <p>I am building a chat app in iOS but I have some problems with the UITableView displaying all the messages. I want the table view to be scrolled to the bottom on load so users can see the latest messages when they open the app.</p>
  
  <p>To do this I added this code in my function refreshing the data:</p>
  
  <pre><code>    NSIndexPath* ipath = [NSIndexPath indexPathForRow: [self.messageOnTimeline numberOfRowsInSection:0]-1 inSection: 0];
      [self.messageOnTimeline scrollToRowAtIndexPath: ipath atScrollPosition: UITableViewScrollPositionTop animated: YES];
  </code></pre>
  
  <p>This worked fine until I added a header to the tableview. I added the following code and now it doesn't scroll to the bottom when I load the app:</p>
  
  <pre><code>-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  {
      UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 30)];
      return view;
  }
  </code></pre>
  
  <p>Does anyone knows why?</p>
  
  <p>Many thanks for your help</p>