I have this code linked to a button on a ViewController with a UITableView as subview:
-(IBAction)Action:(id)sender{
[tableView setContentSize:CGSizeMake(320, 1000)];
}
This makes tha tableView scrollable to the bottom so that I can use a couple of buttons I programatically added to the bottom. So far so good.
However, I want the tableView to be ok from the beginning, so I added the code inside viewDidLoad. Surprisingly, it doesn’t work at all.
Could somebody give me a hand?
thanks!
If your datasource methods are being fired after
viewDidLoad, the tableView content size will be reset when it’s loaded. You’ll need to make sure you’ve calledreloadDatafor the table before the code above. If you’re using a UITableViewController, the order the methods are called is:However, if you want buttons at the end of table, you should put them in the
tableFooterView. You can do this in interface builder easily by dragging a view to the bottom of the tableView. Or you can do it in code (in yourviewDidLoadmethod, for example)Per @Justin’s answer… your question isn’t very clear