文档在这里:https://developer.apple.com/documentation/uikit/uicollectionview/1618056-visiblecells
但我似乎不能使用这个: notesCollectionView.visibleCells() 作为! [NotesCollectionViewCell]
有一个错误: “不能不带参数调用‘visibleCells’”
如何只获取 UICollectionView 中的 visibleCells?
最佳答案
visibleCells
是一个变量,但您使用的是函数调用语法。
删除 () 应该可以解决问题。
if let cells = notesCollectionView.visibleCells as? [NotesCollectionViewCell]
{
// Do your magic here.
}
关于swift - UICollectionView 上的可见单元不能在没有参数的情况下调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56848665/