ios – 带有1个数据源的tableview单元格内的Collectionview

ios – 带有1个数据源的tableview单元格内的Collectionview,第1张

概述我想将集合视图放在tableview单元格中.每个tableview单元格包含2个collectionviewCell.假设我的数据模型中有8张图片,我希望集合视图看起来像图像.这该怎么做? 而不是在tableview中使用集合视图,而是在方法中仅使用带有垂直滚动的集合视图 #pragma mark ------------Collection View Delegates------------ 我想将集合视图放在tablevIEw单元格中.每个tablevIEw单元格包含2个collectionvIEwCell.假设我的数据模型中有8张图片,我希望集合视图看起来像图像.这该怎么做?

解决方法 而不是在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);    }

通过这种方式,您将拥有这样的视图,只需添加pading即可获得结果

总结

以上是内存溢出为你收集整理的ios – 带有1个数据源的tableview单元格内的Collectionview全部内容,希望文章能够帮你解决ios – 带有1个数据源的tableview单元格内的Collectionview所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1029647.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存