简体   繁体   中英

Handling UITableView delegates when the UITableview is a subview of a Custom UIView

I have a UITableView as a subview of my 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.

The UITableView delegates is not being called. My UIView is initialised from the NIB file.

How do I make my ViewController to handle the Delegates of my CustomView

please check that you have set the:

tableView.delegate = self;
tableView.datasource = self;

where self is the controller.

First: the MainViewController must implement the UITableviewDatasource , and UITableViewDelegate protocols. Then, check that the delegate and datasource you set to the tableView is a correct instance of the 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). Hope it's helping u!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM