简体   繁体   中英

Collection View controller not adding as a subview

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 在添加子视图时

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

[self addChildViewController: collectionView];

Try this

Just replace

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

to

[self.view addSubview:collectionView.view];

我认为您应该将collectionView添加为childViewController

I Faced this issue while working on my App.

you are not calling these methods.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM