如何在UIContainerView中连接UICollectionViewController

我有一个应用程序,看起来像这样:

故事板

ViewController是我放入3个容器视图控制器的父VC。
我为所有三个,顶部,中间和BottomContainerViewControllers分类UIViewController

这是我的问题。 我想BottomVC有一个UICollectionView滚动的UICollectionView 。 所以我添加了一个UICollectionView ,你可以看到(给它一个很好的绿色背景)。

但是我的问题是,我怎么把这个钩起来呢?

这是我的BottomContainerViewController.h:

 #import <UIKit/UIKit.h> @interface BottomContainerViewController : UICollectionViewController <UICollectionViewDataSource, UICollectionViewDelegate> @property (nonatomic, retain) IBOutlet UICollectionView *collectionView; @end 

.m文件有以下方法:

 - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath 

但是当我运行它时,我得到:

 [UICollectionViewController loadView] loaded the "qcP-Hl-Txn-view-aJq-Dc-875" nib but didn't get a UICollectionView.' 

UICollectionViewsockets已连接。 还有什么可能是这个问题?

创build一个uiviewcontroller类来pipe理底部的容器。 链接,你通常会使用该视图控制器。 连接委托,数据源,实现委托和数据源等…

我遇到了同样的问题,这是对我有用:
1:单击故事板左下方的“显示文档大纲”button。
2:find应该是UICollectionViewController子类的“Bottom Container View”
3:剪切最高级别视图的子视图(展开第一个视图所看到的所有内容)
4:删除该主视图并粘贴回collections视图

实际上,顶视图必须是UICollectionView,而不是通过将容器放入故事板来默认的UIView。