无法调用非函数类型Swift 3的值

时间:2016-09-22 00:00:34

标签: ios xcode compiler-errors swift3

我正在尝试将我的项目转换为swift 3,但在我的代码中出现以下错误:

代码:

super.collectionView(collectionView, willDisplayCell: cell, forItemAtIndexPath: indexPath)

错误:

无法调用非功能类型'uicollectionview'

的值

有谁知道swift 3编辑?

1 个答案:

答案 0 :(得分:0)

如果你是UICollectionViewController的子类,你应该可以使用它:

override func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
    super.collectionView(collectionView, willDisplay: cell, forItemAt: indexPath)
}

如果你不是UICollectionViewController的子类,你可能不得不使用它:

@objc(collectionView:willDisplayCell:forItemAtIndexPath:) func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {

}

我的应用程序中有两种类型的集合视图,我一直在更新,这对我有用。