8

プロジェクトを Xcode 8 で Swift3 に更新しましたが、このエラーが発生しましたが、そこで何ができるかわかりません。私はすでにグーグルで検索しましたが、何も見つかりませんでした。誰か私が作ることができるアイデアを持っていますか?

ここでエラー:

Objective-C セレクター 'collectionViewContentSize' を持つメソッド 'collectionViewContentSize()' は、同じ Objective-C セレクターを持つスーパークラス 'UICollectionViewLayout' からの 'collectionViewContentSize' のゲッターと競合します

  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!
    }
4

1 に答える 1

41

私は似たようなものを持っていましたが、 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)
}

今日、XCode 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)
}
于 2016-08-03T07:46:47.160 に答える