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?

Answers


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()
}

Need Your Help

Does Python classes support events like other languages?

python events class python-2.7

I'm working on my first Python project, and I'm already missing events in my classes. Perhaps it's not even called events in Python, but I would like to create "groups" in my classes to which funct...

Jtree node expansion without selection

java jtree

Is it possible to expand/collapse a node in a JTree without having it selected? (not highlighted)

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.