ios在UITableView的标题视图中添加了一个collectionView(ios adding a collectionView inside UITableView's header view)

我在我的UITableView的headerView中有一个UICollectionView ,它是在其他xib文件(自定义视图)中创建的。 所以我的问题是,我应该在我声明我的tableView的同一个类上声明委托方法,还是在tableView标题的自定义视图上声明委托方法? 哪个更方便?

I've an UICollectionView inside the headerView of my UITableView which is made in other xib file (custom view) . So my question is, should I declare delegate methods on the same class I've declared my tableView or on the custom view which is header of tableView? Which is more convenient?

最满意答案

在同一个控制器中定义UITableView和UICollectionView的委托,将委托设置为同一个类

self.mytableview.delegate = self; self.mycollectionview.delegate = self;

您可以按照本教程, 将UICollectionView放在UITableViewCell中

Define the delegates of UITableView & UICollectionView in same controller, set there delegates to the same class as

self.mytableview.delegate = self; self.mycollectionview.delegate = self;

You can follow this tutorial, Putting a UICollectionView in a UITableViewCell

ios在UITableView的标题视图中添加了一个collectionView(ios adding a collectionView inside UITableView's header view)

我在我的UITableView的headerView中有一个UICollectionView ,它是在其他xib文件(自定义视图)中创建的。 所以我的问题是,我应该在我声明我的tableView的同一个类上声明委托方法,还是在tableView标题的自定义视图上声明委托方法? 哪个更方便?

I've an UICollectionView inside the headerView of my UITableView which is made in other xib file (custom view) . So my question is, should I declare delegate methods on the same class I've declared my tableView or on the custom view which is header of tableView? Which is more convenient?

最满意答案

在同一个控制器中定义UITableView和UICollectionView的委托,将委托设置为同一个类

self.mytableview.delegate = self; self.mycollectionview.delegate = self;

您可以按照本教程, 将UICollectionView放在UITableViewCell中

Define the delegates of UITableView & UICollectionView in same controller, set there delegates to the same class as

self.mytableview.delegate = self; self.mycollectionview.delegate = self;

You can follow this tutorial, Putting a UICollectionView in a UITableViewCell