gpt4 book ai didi

ios - 滚动直到 uicollectionview 的最后一个单元格

转载 作者:行者123 更新时间:2023-11-30 11:45:37 28 4
gpt4 key购买 nike

我在滚动 collectionView 时遇到问题选择单元格后,最后一个单元格不可选择 under this cell there is another cell but there is not any space for scrolling

unavailable last cell can not scroll to reach it

   func changeViewSize(from: CGFloat, to: CGFloat, indexPath: IndexPath) {
UIView.transition(with: myCollection, duration: 0.5, options: .beginFromCurrentState, animations: {() -> Void in
let cell = self.myCollection.cellForItem(at: indexPath)!
let cellCenter = CGPoint(x: cell.center.x, y: cell.center.y + 50)
if cell.bounds.height == from {
let sizee = CGRect(x: cell.center.x, y: cell.center.y, width: cell.frame.width, height: to)
self.myCollection.cellForItem(at: indexPath)?.frame = sizee
self.myCollection.cellForItem(at: indexPath)?.center = cellCenter
for x in self.indexPathss {
if x.row > indexPath.row {
print("this is cells")
print(self.myCollection.visibleCells)
let cell = self.myCollection.cellForItem(at: x)!
cell.center.y += 100
}
}
}
}, completion: {(_ finished: Bool) -> Void in
print("finished animating of cell!!!")
})
}

最佳答案

您似乎正在手动更改单元格大小和位置。 UICollectionView 不会意识到这些变化,因此它的大小不会改变。最后的单元格只是移出了 Collection View 的可见区域。

我以前没有做过类似的事情,但是看看 performBatchUpdates(_:completion:) 。我会尝试使用该方法重新加载您想要增大的单元格。您的布局必须提供正确的属性,即大小。

从屏幕截图来看,也许您可​​以使用 UITableView 来代替?如果有可能的话,事情可能会简化。它还具有 performBatchUpdates(_:completion:) 方法,并且 UITableViewDelegate 必须提供正确的 heights for the rows .

关于ios - 滚动直到 uicollectionview 的最后一个单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48856543/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com