【发布时间】:2016-12-02 18:15:28
【问题描述】:
我正在尝试为集合视图中的单元格大小更改设置动画。
在“didSelectItemAt”中:
collectionView.performBatchUpdates({
collectionView.collectionViewLayout.invalidateLayout()
let cell = collectionView.cellForItem(at: indexPath)
let frame = cell?.frame
cell?.frame = CGRect(x: (frame?.origin.x)!, y: (frame?.origin.y)!, width: (frame?.size.width)! + 100, height: (frame?.size.height)!)
}, completion: nil)
这应该设置单元格的大小,但没有任何反应。再次单击单元格,我看到单元格的大小保持为 size+100(忽略它每次都会增长的事实 - 只是试图让它立即工作)。
在 sizeForItemAt 函数中,任何检索单元格的尝试都返回 nil。
collectionView.numberOfItems(inSection: indexPath.section)
返回 3,但是
collectionView.cellForItem(at: indexPath)
返回零。为什么?
如何在 sizeForItemAt 范围内获取具有给定索引路径的集合视图的单元格:???
【问题讨论】:
标签: ios uicollectionview swift3 uicollectionviewcell