我已经为 UICollectionViewDelegateFlowLayout 实现了这个委托方法,但是当试图将单元格出队时,我收到了这个错误:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
如果我尝试这样做,我也会得到这个:let cell = collectionView.cellForItem(at: indexPath) as! RQTTipCell
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "TipCell", for: indexPath) as! RQTTipCell
let height = self.proxyView!.tipCollect.contentSize.height
let width = cell.bagRatio.multiplier / height
return CGSize(width: width, height: height)
}
这个 indexPath 应该是正确的,但似乎不是。