Objective C: How do I add custom table view cells to a subview of a UIViewController
I currently have a UIViewController displaying a map view. I would like to display some cu开发者_开发知识库stom table view cells when I tap on a button within the same UIViewController. Can I do that? Or do I need to set the table view cells within a UITableViewController?
Thanks for any advise here.
Zhen Hoe
You should use a UIViewController
subclass rather than a subclass of UITableViewController
to manage a table view if the view to be managed is composed of multiple subviews, one of which is a table view. The default behavior of the UITableViewController
class is to make the table view fill the screen between the navigation bar and the tab bar (if either are present).
I would like to display some custom table view cells when I tap on a button within the same UIViewController.
If you want to show your table view along with other views, you can add a UITableView
subview and make your controller implement UITableViewDelegate
and UITableViewDataSource
protocols.
You need to create a UITableViewController
, and then set the contents of the UITableViewCells
using the - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
delegate method.
精彩评论