Vadim Nikolaev
Vadim Nikolaev

Reputation: 2132

Cells of CollectionView don't fit in screen

I have CollectionView in cell of TableView: enter image description here

enter image description here

Constraints for cell in CollectionView

enter image description here

When I run app f.e. on iPhone 5s I see (cell doesn't fit at screen): enter image description here

But after scroll down and up I see: enter image description here

I know about reuse, but how to show cell from start as must (fit to screen)?

Upvotes: 0

Views: 737

Answers (1)

Dhiru
Dhiru

Reputation: 3060

You Need to reaload your Collection View

In your TableViewCell Impleament Method

    func draw(_ rect: CGRect)
    {

// here you have to reaload your collectionView
        super.draw(rect)
    self.collectionView.realodData()

    }

refresh your TableCell By Calling its DrawRect Method

optional func tableView(_ tableView: UITableView, 
            willDisplay cell: UITableViewCell, 
               forRowAt indexPath: IndexPath)
{
  cell.setNeedsDisplay()
}

i hope this will work for you,

Upvotes: 1

Related Questions