-3

I am trying to push a UICollectionViewController when a button is pressed. I'm using this to push it:

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

But when I tap on the button the app crashes and gives me this message: UICollectionView must be initialized with a non-nil layout parameter
In my RewardsCollectionViewController class I haven't done anything I just changed numberOfItemsInSection to 1.

There might me a possible solution here but I didn't find my answer on that page. As it is somehow related to UICollectionViewFlowLayout and I have no idea what that is.

Community
  • 1
  • 1
Chaudhry Talha
  • 4,570
  • 7
  • 30
  • 71

1 Answers1

1

Give the storyboard to your COllectionViewController after that change your code like this

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

Hope this will help you

Nirav D
  • 65,660
  • 11
  • 144
  • 172