title: What is the right place to add a subview dependent on scrollView.contentSize?
body: <p>I'm using <a href="http://www.cocoanetics.com/2009/12/how-to-make-a-pull-to-reload-tableview-just-like-tweetie-2/" rel="nofollow">Cocoanetic's pull-to-reload</a> but with a twist: I would like the UITableView to be able to pull up, as it were, to load more data.</p>
  
  <p>I customized the classes and have managed to adjust all functionality to support this. What got me stumped, basically, is where in my code to create and add the extra view.</p>
  
  <p>I first tried to add it in viewDidLoad of Cocoanetic's class (a <code>UITableViewController</code>):</p>
  
  <pre><code>- (void)viewDidLoad 
  {
      [super viewDidLoad];
      refreshHeaderView = [[EGORefreshTableHeaderView alloc] initWithFrame:CGRectMake(0.0f, 0.0f - self.view.bounds.size.height, 320.0f, self.view.bounds.size.height)];
      refreshFooterView = [[EGORefreshTableFooterView alloc] initWithFrame:CGRectMake(0.0f, 0.0f + self.tableView.contentSize.height, 320.0f, 20.0f)];
      [self.tableView addSubview:refreshHeaderView];
      [self.tableView addSubview:refreshFooterView];
      self.tableView.showsVerticalScrollIndicator = YES;
  }
  </code></pre>
  
  <p>This does not work, as <code>self.tableView.contentSize.height</code> is zero at this point, because the table hasn't loaded it's data yet.</p>
  
  <p>Not to worry, I thought, and tried to add it in the viewDidLoad of the UITableViewController subclass I made:</p>
  
  <pre><code>- (void)viewDidLoad
  {
      [super viewDidLoad];
      // stuff
      self.model = [ListingModel listingModelWithURL:@"avalidurl" delegate:self];
      refreshFooterView = [[EGORefreshTableFooterView alloc] initWithFrame:CGRectMake(0.0f, 0.0f + self.tableView.contentSize.height, 320.0f, 20.0f)];
      [self.tableView addSubview:refreshFooterView];
  }
  </code></pre>
  
  <p>Note I set the model first, but that also didn't work, for the same reason. I assume the table hasn't been layed-out yet. In frustration I gave my class a <code>BOOL</code> property and an <code>addFooter</code> method (the <code>BOOL</code> to make sure it's only called once) called from <code>tableView:cellForRowAtIndexPath:</code> which obviously is a far cry from The Right Way™</p>
  
  <p>So what would, given this scenario, be The Right Way™?</p>