如何将collectionview作为子视图添加到viewcontroller

时间:2014-05-21 17:23:20

标签: ios objective-c uiviewcontroller uicollectionview

当我想将它作为子视图添加到我的ProfileViewController时,我的collectionview有点问题。当我想重新加载collectionview时出现问题,xcode给我一个错误属性'collectionview'找不到类型为ProfileViewController的对象。 我该如何克服这个问题?我是否要创建一个新的collectionview类文件并将其设置为ProfileViewController上的collectionview?下面是我的故事板的图像。

故事板的图像位于此链接。 http://i.stack.imgur.com/XSE29.png。 我无法将图像附加到此帖子,因为我的声誉很低。

1 个答案:

答案 0 :(得分:0)

您需要确保您的ProfileViewController符合UICollectionViewDataSource和UICollectionViewDelegate协议,并且当您在ProfileViewController中创建集合视图时,请确保执行以下操作:

collectionView.delegate = self;
collectionView.dataSource = self;

听起来你正在尝试使用self.collectionView,其中该属性在ProfileViewController上不存在。

相关问题