开发者

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 UITableViewDelegateand 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜