Ios 具有1个数据源的tableview单元格内的Collectionview
我想把集合视图放在tableview单元格中。每个tableview单元格包含2个collectionviewCell。假设我的数据模型中有8张图片,我希望集合视图看起来像图像。如何做到这一点Ios 具有1个数据源的tableview单元格内的Collectionview,ios,swift,uitableview,uicollectionview,Ios,Swift,Uitableview,Uicollectionview,我想把集合视图放在tableview单元格中。每个tableview单元格包含2个collectionviewCell。假设我的数据模型中有8张图片,我希望集合视图看起来像图像。如何做到这一点 不要在tableview中使用集合视图,而应在方法中仅使用带有垂直滚动的集合视图 #pragma mark ------------Collection View Delegates----------------- override func numberOfSectionsInCollectio
不要在tableview中使用集合视图,而应在方法中仅使用带有垂直滚动的集合视图
#pragma mark ------------Collection View Delegates-----------------
override func numberOfSectionsInCollectionView(collectionView:
UICollectionView!) -> Int {
return 1
}
override func collectionView(collectionView: UICollectionView!,
numberOfItemsInSection section: Int) -> Int {
return 4
}
override func collectionView(collectionView: UICollectionView!,
cellForItemAtIndexPath indexPath: NSIndexPath!) ->
UICollectionViewCell! {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier,
forIndexPath: indexPath) as !MyCollectionViewCell
// Configure the cell
let image = UIImage(named: Images[indexPath.row])
cell.imageView.image = image
return cell
}
func collectionView(collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
return CGSizeMake(_collectionViewToAddImages.frame.size.width/2, _collectionViewToAddImages.frame.size.height/2);
}
这样,您就可以看到这样的视图,只需添加焊盘,您就会得到结果问题到底是什么?你不能把它放在情节提要上?我已经把集合视图放在情节提要的tableview上了,我认为正确的问题是,如何将它与一个数据源一起使用?我的意思是img0-img1和img2-img3不在同一个tableViewcell@heximalKeep数组或字典中的图像,并从willDisplayCell获取所需的图像…问题是我需要在每一行显示背景图像(看我问题中的橙色矩形)@HilmanI尝试将我的代码转换成swift…我没有太多使用swift,所以请注意是否有语法错误。