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

在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)

这样就显示了

请问这是什么原因?

巴扎黑
巴扎黑

reply all(2)
大家讲道理

Print out videoView.frame = cell.frame in cell.frame and you will know~

刘奇

Set a breakpoint at cellForItemAtIndexPath and check whether cell.frame is what you expected. But why not use auto layout

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!