[英]add a collection view controller to another controller as subview
I am trying to add a collectionViewController
to another controller as subview. 我试图将collectionViewController
添加到另一个控制器作为子视图。
datasource
and delegate
methods are called. 调用datasource
和delegate
方法。
I can interact with the cells ie, I can call didSelectItemAtIndexpath
, but i can't see anything. 我可以与单元格进行交互,即可以调用didSelectItemAtIndexpath
,但是什么也看不到。
Please let me know if I did anything wrong. 如果我做错了任何事情,请告诉我。
HairTypeFilterController *htfvc=[self.storyboard instantiateViewControllerWithIdentifier:@"hairTypeFilterSBID"];
[self addChildViewController:htfvc];
[htfvc didMoveToParentViewController:self];
htfvc.view.frame=CGRectMake(0, 0, _filterDetailsOutlet.frame.size.width, _filterDetailsOutlet.frame.size.height);
[_filterDetailsOutlet addSubview:htfvc.collectionView];
I resolved my problem by removing the below single line of code which was by default implemented inside uicollectionviewcontrollerclass
. 我通过删除下面的单行代码(默认情况下在uicollectionviewcontrollerclass
内部实现)解决了我的问题。 Now its working. 现在可以正常工作了。
// Register cell classes
[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:reuseIdentifier];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.