2016-08-02 59 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) 
}