Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/101.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITableViewController如何知道其数据源和委托_Ios_Ios5_Uitableview - Fatal编程技术网

Ios UITableViewController如何知道其数据源和委托

Ios UITableViewController如何知道其数据源和委托,ios,ios5,uitableview,Ios,Ios5,Uitableview,我正在学习BigNerdRanch iOS编程书,这一章是关于UITableViewController的。然而,我一直在想,UITableViewController在哪里找到了它的委托和数据源。目前我把它作为 @interface ItemsViewController:UITableViewController 但没有什么看起来像: [self.tableView setDelegate:self] 我只是想知道UITableViewController是如何发现其委托和数据源的您可以通过

我正在学习BigNerdRanch iOS编程书,这一章是关于UITableViewController的。然而,我一直在想,
UITableViewController
在哪里找到了它的
委托
数据源
。目前我把它作为

@interface ItemsViewController:UITableViewController

但没有什么看起来像:

[self.tableView setDelegate:self]


我只是想知道UITableViewController是如何发现其委托和数据源的

您可以通过接口生成器(在Xcode中)或通过编程方式(通过和)在表视图对象(在xib或情节提要文件中)上设置委托和数据源的


注意,您正在表视图控制器管理的表视图(即两个不同的对象)上设置这些内容。

您可以通过Interface Builder(在Xcode中)或编程方式,通过和在表视图对象(在xib或情节提要文件中)上设置委托和数据源


注意,您正在表视图控制器管理的表视图上设置这些内容(即两个不同的对象)。

如果您自己设置
UITableView
,则必须将其指向委托和数据源

UITableViewController
设置
UITableView
并将委托和数据源属性设置为自身。当您子类化UITableViewController时,您可以免费获得此行为


您的问题有缺陷,因为
UITableViewController
没有数据源和委托,它所控制的
UITableView
有数据源和委托。而
UITableViewController
是数据源和委托,因为它是这样设置的。

如果您自己设置
UITableView
,则必须将其指向委托和数据源

UITableViewController
设置
UITableView
并将委托和数据源属性设置为自身。当您子类化UITableViewController时,您可以免费获得此行为


您的问题有缺陷,因为
UITableViewController
没有数据源和委托,它所控制的
UITableView
有数据源和委托。而
UITableViewController
是数据源和委托,因为它以这种方式进行设置。

首先声明:

@interface ItemsViewController : UITableViewController <UITableViewDataSource, UITableViewDelegate>

首先,宣言:

@interface ItemsViewController : UITableViewController <UITableViewDataSource, UITableViewDelegate>