2016-09-22 34 views
1

我想我的項目轉換爲快捷3,但讓我的代碼以下錯誤:不能調用價值的非功能類型斯威夫特3

代碼:

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

錯誤:

不能調用非功能類型'uicollectionview'的值

有沒有人知道swift 3編輯?

回答

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) { 

} 

我都我已更新的應用中的收集視圖類型,這對我來說很有用。