本文介绍了UITableViewController与TableView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将Table View Controller拖到情节提要中与将UI View Controller拖到xCode中的Table View内之间有什么区别?

What is the difference between dragging a Table View Controller into the storyboard vs dragging a UI View Controller and dragging a Table View inside that in xCode?

我知道如何用代码填充表视图控制器.

I know how to populate a table view controller in code.

- (UITableViewCell *)tableView:(UITableView *)tableView
                     cellForRowAtIndexPath:(NSIndexPath *)indexPath;

如何在UI View Controller中填充表格视图?我将哪些自定义类委托给UI视图?我似乎无法在上面放一个tableViewController,因为它只是一个带有表视图的ViewController ...

How do I populate a table view within a UI View Controller? What custom class do I delegate to the UI View? I cannot seem to put a tableViewController on it as it is only a ViewController with a table view...

我想知道这一点,因为我想在该视图中拥有除表以外的其他对象(即视图的一部分用于表,另一部分包含标签,图像和按钮) )

I'd like to know this because I'd like to have objects other than the table in that view (i.e. a section of the view is for the table and the other section contains a label, an image, and a button.)

推荐答案

在UIViewController内部填充UITableView与在UITableViewController内部填充UITableView没什么不同.您只需要确保实现所需的数据源和委托方法即可.您还需要确保将UIViewController分配为该UITableView的委托和数据源.

Populating a UITableView inside of a UIViewController is no different than populating a UITableView inside of a UITableViewController. You just have to make sure you implement the required datasource and delegate methods. You also need to be sure to assign the UIViewController as the delegate and the datasource for that UITableView.

如果要使用表以外的对象,则应该使用UIViewController.实际上,我很少再使用UITableViewController,以防万一我需要添加其他对象.

If you want objects other than the table, then you should us a UIViewController. In fact, I rarely use the UITableViewController any more just in case I need to add other objects.

这篇关于UITableViewController与TableView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 02:02