Borut Tomazin
Borut Tomazin

Reputation: 8138

CollectionViewFlowLayout's collectionViewContentSize() in swift

I cannot retrieve contentSize from flow layout with the following code

let contentSize: CGSize = self.collectionView?.collectionViewLayout.collectionViewContentSize()!

Instead I get error:

Could not find member 'collectionViewContentSize'

If I print value it returns properly:

println("content size \(self.collectionView?.collectionViewLayout.collectionViewContentSize())")

Is this swift compiler issue?

Upvotes: 0

Views: 1096

Answers (1)

hris.to
hris.to

Reputation: 6363

You must cast collectionViewLayout to specific layout. If you use UICollectionViewFlowLayout it will look something like this:

if let flow = collectionMain.collectionViewLayout as? UICollectionViewFlowLayout
{
    let contentSize: CGSize = flow.collectionViewContentSize()
}

Upvotes: 2

Related Questions