ios - 在UICollectionView的cell中添加subView不显示的问题
巴扎黑
巴扎黑 2017-04-17 13:41:03
0
2
288

在cellForItemAtIndexPath方法中
var videoView = videos["video"] as UIView
videoView.frame = cell.frame
self.collectionView.addSubview(videoView)

如果我设置了 videoView.frame = cell.frame 这句,那么这个subview 就不会显示

我修改了frame(包含在cell中)

var videoView = videos["video"] as UIView
videoView.frame = videoView.frame = CGRect(x: 37, y: 94, width: 100, height: 100)
self.collectionView.addSubview(videoView)

这样就显示了

请问这是什么原因?

巴扎黑
巴扎黑

全部回复(2)
大家讲道理

videoView.frame = cell.framecell.frame打印出来看看不就知道啦~

刘奇

在cellForItemAtIndexPath处设置断点,检查cell.frame是否是你预期的。不过话说为什么不用auto layout

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!