CollectionView的单元格不适合屏幕

时间:2017-05-25 18:16:22

标签: ios swift uicollectionview

我在CollectionView的单元格中有TableViewenter image description here

enter image description here

CollectionView

中单元格的约束

enter image description here

当我运行app f.e.在iPhone 5s我看到(单元格不适合屏幕): enter image description here

但向下滚动后,我看到: enter image description here

我知道重用,但是如何从头开始显示单元格(适合屏幕)?

1 个答案:

答案 0 :(得分:1)

您需要自动加载收藏视图

在TableViewCell实施方法

    func draw(_ rect: CGRect)
    {

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

    }

通过调用其DrawRect方法刷新您的TableCell

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

我希望这对你有用,