views:

214

answers:

3

I'm trying to write an iPhone app where one of the main pages has a few text fields and a 3-element table that basically work as navigation buttons to pickers.

However, all of the tutorial examples I've found treat tables as something that takes over the whole view.

Can anyone point me to examples where a table is only a PART of a view?

+1  A: 

I don't know of any examples offhand, but a UITabelView is just a view and so can be any size you wish. You need to have a view controller that's derived from UIViewController (and not UITableViewController) but that implements the data source and delegate functionality for a table view.

For what it's worth many of the iPhone screens that look like views + table (e.g. an address book entry) are actually just tables with certain rows having a custom height and contents.

Andrew Grant
+3  A: 

There are two different objects in play here: UITableViewController (which by default creates a UITableView that takes over the whole screen) and UITableView. You want to create a UITableView that is smaller than the screen. Use your simplest UIViewController (not UITableViewController) Interface Builder example, drag a UITableView onto the view, resize it to be smaller than the screen, and make sure it has a delegate and datasouce connection. Voila!

Trent Davies
A: 

In IB, start with a View - add all the controls you like to this, and also drag in a table to whatever size you like.

Then in the view controller for the view, add an IBOutlet property to hold the UITableView you have drug in, and link it in IB to the View Controller file's owner.

Now, you can also make your view controller conform to the UITableViewDelegate and UITableViewDataSource protocols, and add the table delegate methods in there (easiest way is to make a new UITableViewController subclass from the template and then drag the methods into your view controller).

Don't forget to link the UITableView delegate and datasource references in IB back to the File's Owner.

Kendall Helmstetter Gelner