2016-08-02 33 views
8

我已經更新我的項目到Swift3在Xcode 8,它出現這個錯誤,但我不知道我可以在那裏做什麼。我已經在谷歌搜索,但沒有成立。 有誰有想法我可以做什麼?在Swift3 func collectionViewContentSize

在這裏,錯誤:

方法 'collectionViewContentSize()' 與目標C選擇 'collectionViewContentSize' 與吸氣劑具有相同的目標C選擇

public func collectionViewContentSize() -> CGSize { 
     let numberOfSections = collectionView?.numberOfSections 
     if numberOfSections == 0 { 
      return CGSize.zero 
     } 

     var contentSize = collectionView?.bounds.size 
     contentSize?.height = CGFloat(columnHeights[0]) 

     return contentSize! 
    } 
衝突關於 'collectionViewContentSize' 從超類UICollectionViewLayout'

回答

33

我有類似的東西,但我重寫collectionViewContentSize()

override func collectionViewContentSize() -> CGSize { 
    let collection = collectionView! 
    let width = collection.bounds.size.width 
    let height = max(posYColumn1, posYColumn2) 

    return CGSize(width: width, height: height) 
} 

我下載X代碼8 beta 4今天,不得不將其更改爲:

override var collectionViewContentSize: CGSize { 
    let collection = collectionView! 
    let width = collection.bounds.size.width 
    let height = max(posYColumn1, posYColumn2) 

    return CGSize(width: width, height: height) 
}