Question

i have a collection view controller if i add it as sub view as

YDCollectionViewCtr *collectionView = [self.storyboard instantiateViewControllerWithIdentifier:@"collectionview"];//collectionview
     collectionView.view.frame = CGRectMake(0, 154, 320, 300);
    collectionView.bussnessdic =bussinessphotoDic;
   [self.navigationController.view addSubview:collectionView.view];

or [self.view addSubview:collectionView.view];

than just a black screen is added while adding subview

but when i push it it works perfectly..... I need to add it as subview. Any kind of help will be appreciable while pushing

Was it helpful?

Solution

[self addChildViewController: collectionView];

OTHER TIPS

Try this

Just replace

[self.navigationController.view addSubview:collectionView.view];

to

[self.view addSubview:collectionView.view];

I Faced this issue while working on my App.

you are not calling these methods.

[self.CollectionView.collectionViewLayout collectionViewContentSize];
[self.CollectionView reloadData];

I think you should add collectionView as a childViewController

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top