title: UITableView tableFooterView weird resizing
body: <p>I want to display a UIButton in a UITableView's Footer (should be exactly the same for the header).</p>
  
  <p>This code is in the viewDidLoad of my TableViewController:</p>
  
  <pre><code>UIButton *footerShareButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
  [footerShareButton setFrame:CGRectMake(10, 0, 70, 50)];
  NSLog(@"%f", footerShareButton.frame.size.width);
  
  [self.tableView setTableFooterView:footerShareButton];
  
  NSLog(@"%f", footerShareButton.frame.size.width);
  NSLog(@"%f", self.tableView.tableFooterView.frame.size.width);
  </code></pre>
  
  <p>However, this code doesn't work. The Button's width is much too large, it's 320. (The height is correct though.) The first NSLog outputs 70, the second and the third output 320. So it seems like the setTableFooterView method strangely resizes the button.</p>
  
  <p>I have solved this problem by putting the UIButton in another UIView before setting it as the table footer:</p>
  
  <pre><code> UIButton *footerShareButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
   [footerShareButton setFrame:CGRectMake(10, 0, 70, 50)];
  
   UIView *aView = [[UIView alloc] initWithFrame:CGRectMake(10, 0, 70, 50)];
   [aView addSubview:footerShareButton];
  
   [self.tableView setTableFooterView:aView];
   [aView release];
  </code></pre>
  
  <p>This works, the button has the correct width.</p>
  
  <p>However, I don't understand why the first code sample doesn't work. Can anyone explain?</p>