I want to have a UICollectionView
where the cells are also UICollectionView
s. Is this possible and if so, could someone give me a guide on how to start this? I already have my main UICollectionView
, but I'm having trouble implementing another UICollectionView
in its UICollectionViewCell
.
I did something similar some time ago. Inside your cellForItemAtIndexPath: of your parent CollectionView you have to do something like below. I havent tested this so you might have to add in some code:
ChildCollectionViewController * cv = //Initialize your secondCVController here
if (!cv) {
cv = [self.storyboard instantiateViewControllerWithIdentifier:@"collectionViewID”]; //set your class’s storyboard ID before doing this
cv.view.frame = cell.contentView.bounds;
[self addChildViewController:cv];
[cell.contentView addSubview:cv.view];
[cv didMoveToParentViewController:self];
}
//Some code here for cell contents
return cell;
}
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.