1

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?

enter image description here Let's say I have 2 collection views which should cover and fit adaptively on different device screen sizes.

Mihail Duchev
  • 4,691
  • 10
  • 25
  • 32
letsCode
  • 31
  • 7
  • 1
    Can you post photos of the layout on the 2 different phones and a photo of your ideal layout? – rs7 Jun 14 '20 at 20:59

1 Answers1

0

In your custom 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

self.collectionView.layoutIfNeeded()
self.contentView.layoutIfNeeded()
Rishabh Shukla
  • 461
  • 6
  • 19