簡體   English   中英

將集合視圖控制器添加到另一個控制器作為子視圖

[英]add a collection view controller to another controller as subview

我試圖將collectionViewController添加到另一個控制器作為子視圖。

調用datasourcedelegate方法。

我可以與單元格進行交互,即可以調用didSelectItemAtIndexpath ,但是什么也看不到。

如果我做錯了任何事情,請告訴我。

 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];

我通過刪除下面的單行代碼(默認情況下在uicollectionviewcontrollerclass內部實現)解決了我的問題。 現在可以正常工作了。

// Register cell classes 
[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:reuseIdentifier]; 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM