如何将故事板视图添加到 cell.contentView?
How to add a storyboard view into a cell.contentView?
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"TNCNewsRow" bundle:nil];
TNCNewsRowViewController *rowVC = (TNCNewsRowViewController*)[storyboard instantiateViewControllerWithIdentifier:@"storyboard2"];
NSArray *news = [_news objectAtIndex:indexPath.section];
rowVC.news = news;
cell.contentView = rowVC; // ??
return cell;
}
我正在尝试将 CollectionViewB 添加到另一个 CollectionViewA 的单元格中。
但我不确定如何以编程方式执行此操作。
[cell.contentView addSubview: rowVC.view];
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"TNCNewsRow" bundle:nil];
TNCNewsRowViewController *rowVC = (TNCNewsRowViewController*)[storyboard instantiateViewControllerWithIdentifier:@"storyboard2"];
NSArray *news = [_news objectAtIndex:indexPath.section];
rowVC.news = news;
cell.contentView = rowVC; // ??
return cell;
}
我正在尝试将 CollectionViewB 添加到另一个 CollectionViewA 的单元格中。 但我不确定如何以编程方式执行此操作。
[cell.contentView addSubview: rowVC.view];