当前位置: 动力学知识库 > 问答 > 编程问答 >

uitableview - How do you have a table and other elements on the same iPhone view?

问题描述:

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?

网友答案:

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!

网友答案:

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.

网友答案:

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: