Tag: prepareforreuse

如何重新绘制不可见的UICollectionViewCell的旋转后准备好重用时发生?

如何重绘不可见的UICollectionViewCell准备好时重用发生? 我想到的一种方法是在Layout Cell prepareForReuse函数中使用代码,但是它的工作原理是非最优的,因为它会导致需要更多的重绘。 背景:在当前不可见的方向改变之后,需要为单元格触发drawRect ,但是popup来使用并且没有被重画,所以到目前为止,我只能看到prepareForReuse是合适的。 问题是我正在重新绘制所有的“重用”单元格,而我真的只想重绘那些最初popup在设备的前一个方向位置创build的单元格。 其他信息:所以目前我正在这样做: 在ViewController中: override func viewWillLayoutSubviews() { // Clear cached layout attributes (to ensure new positions are calculated) (self.cal.collectionViewLayout as! GCCalendarLayout).resetCache() self.cal.collectionViewLayout.invalidateLayout() // Trigger cells to redraw themselves (to get new widths etc) for cell in self.cal?.visibleCells() as! [GCCalendarCell] { cell.setNeedsDisplay() } // Not sure how to "setNeedsDisplay" on […]