views:

30

answers:

1

In Interface Builder, you have to set the size of the tableview and position the other elements beneath that. I want the tableview to be sized to fit any number of rows and the buttons to be moved down relative to the tableview.

Is it possible to do this without building the whole thing programmatically?

+3  A: 

You should embed the buttons within a UIView, and set that UIView as the tableFooterView of the UITableView. You can do this in IB by dragging the view into the bottom of the UITableView. This way the buttons will always be below the last row of the tableview, though I should warn you that if there are more rows than fit on-screen, the buttons won't be visible until you scroll down. If this isn't what you want, then you'll need to do something more complicated (namely, run -layoutSubviews on the UITableView, then ask it for the rect of the last section, and use that to calculate where the buttons should go).

Kevin Ballard
Thanks, I had considered the first option but I wasn't sure if it was good practice or not. If the situation was more complicated, like a couple tableviews and a couple sets of buttons, would it be possible/bad practice to have a grouped master table view, where each cell is a tableview, a button, or a few buttons?
Rob Lourens
That may not be so much of a problem of bad practice as it is of bad design. If you have multiple tables that are tall enough to contain all rows without scrolling, consider condensing them into a single table instead.
Ed Marty