[英]how to fit collection view cell in table view cell ( adaptive on all screen sizes?)
My collection view cells (7 cells) need to fit into table view cell, but when I run it it shows differently in iPhone 6 and iPhone X. Is there any way that I can overcome the issue?我的集合视图单元格(7 个单元格)需要适合表格视图单元格,但是当我运行它时,它在 iPhone 6 和 iPhone X 中的显示不同。有什么办法可以克服这个问题吗?
Let's say I have 2 collection views which should cover and fit adaptively on different device screen sizes.假设我有 2 个集合视图,它们应该覆盖并适应不同的设备屏幕尺寸。
In your custom UITableViewCell在您的自定义 UITableViewCell
override func systemLayoutSizeFitting(_ targetSize: CGSize, withHorizontalFittingPriority horizontalFittingPriority: UILayoutPriority, verticalFittingPriority: UILayoutPriority) -> CGSize {
self.contentView.frame = self.bounds
self.contentView.layoutIfNeeded()
self.collectionView.reloadData()
return self.collectionView.contentSize
}
and when u are configuring the cell means u are passing data From controller to your UITableViewCell use this in that当你正在配置单元格时,意味着你正在将数据从 controller 传递到你的 UITableViewCell 使用这个
self.collectionView.layoutIfNeeded()
self.contentView.layoutIfNeeded()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.