[英]Handling UITableView delegates when the UITableview is a subview of a Custom UIView
I have a UITableView as a subview of my CustomView. 我有一个UITableView作为我的CustomView的子视图。
I have initialised my custom view and since the UITableview is an outlet of my CustomView, I am trying to set the delegates of the UITableview in my main view controller. 我初始化了我的自定义视图,因为UITableview是我的CustomView的插座,我试图在我的主视图控制器中设置UITableview的委托。
The UITableView delegates is not being called. 未调用UITableView委托。 My UIView is initialised from the NIB file. 我的UIView是从NIB文件初始化的。
How do I make my ViewController to handle the Delegates of my CustomView 如何让我的ViewController处理我的CustomView的代理
please check that you have set the: 请检查您是否设置了:
tableView.delegate = self;
tableView.datasource = self;
where self
is the controller. self
是控制者。
First: the MainViewController
must implement the UITableviewDatasource
, and UITableViewDelegate
protocols. 第一: MainViewController
必须实现UITableviewDatasource
和UITableViewDelegate
协议。 Then, check that the delegate and datasource you set to the tableView is a correct instance of the MainViewController
. 然后,检查您设置到tableView的委托和数据源是否是MainViewController
的正确实例。 If you connect the delegate and datasource of the table view from the Interface builder, maybe you have to import the "MainViewController.h"
in your CustomView
(if I understood correctly). 如果从“接口”构建器连接表视图的委托和数据源,则可能必须在CustomView
导入"MainViewController.h"
(如果我理解正确的话)。 Hope it's helping u! 希望它能帮到你!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.