CollectionView的单元格不适合屏幕

我在TableView单元格中有CollectionView在这里输入图像说明

在这里输入图像说明

CollectionView单元格的约束

在这里输入图像说明

当我在iPhone 5s上运行app fe时,我发现(单元格不适合屏幕显示): 在这里输入图像说明

但是,滚动后,我看到: 在这里输入图像说明

我知道重用,但如何显示细胞从开始必须(适合屏幕)?

你需要reaload你的collections视图

在你的TableViewCell Impleament方法中

  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() } 

我希望这会为你工作,