Cells of CollectionView don't fit in screen

2019-08-27 18:11发布

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

1条回答
神经病院院长
2楼-- · 2019-08-27 18:35

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,

查看更多
登录 后发表回答