【问题标题】:How to push a UICollectionView programmatically? [duplicate]如何以编程方式推送 UICollectionView? [复制]
【发布时间】:2016-06-21 11:53:00
【问题描述】:

当按下按钮时,我试图按下UICollectionViewController。我正在使用它来推送它:

RewardsCollectionViewController* rvc = [[RewardsCollectionViewController alloc] init];                 
[self.navigationController pushViewController:rvc animated:YES];

但是当我点击按钮时,应用程序崩溃并给我以下消息: UICollectionView must be initialized with a non-nil layout parameter
在我的RewardsCollectionViewController 课堂上我什么都没做,我只是将numberOfItemsInSection 更改为1

我可能有一个可能的解决方案here,但我没有在该页面上找到我的答案。因为它在某种程度上与UICollectionViewFlowLayout 有关,我不知道那是什么。

【问题讨论】:

标签: ios objective-c uicollectionview


【解决方案1】:

storyboard 提供给您的COllectionViewController,然后像这样更改您的代码

 RewardsCollectionViewController* rvc = [self.storyboard instantiateViewControllerWithIdentifier:@"yourIdentifer"];                 
 [self.navigationController pushViewController:rvc animated:YES];

希望对你有帮助

【讨论】:

    猜你喜欢
    • 2017-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-22
    • 1970-01-01
    • 2020-02-03
    • 2018-04-26
    相关资源
    最近更新 更多