在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)
这样就显示了
请问这是什么原因?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
在
videoView.frame = cell.frame把cell.frame打印出来看看不就知道啦~在cellForItemAtIndexPath处设置断点,检查cell.frame是否是你预期的。不过话说为什么不用auto layout