Exception after settings UICollectionView with autosizing cell

Viewed 253

I carefully followed that exemple to transform my collectionView to use dynamic height while using Nibs.

After setting the estimatedItemSize in viewDidLoad here:

override func viewDidLoad() {
    super.viewDidLoad()
    if let layout = self.collectionView.collectionViewLayout as? UICollectionViewFlowLayout {
        layout.estimatedItemSize = UICollectionViewFlowLayoutAutomaticSize
    }
}

I get this exception:

2017-09-14 16:03:06.686930-0400 ClientCenterApp[404:48958] *** Assertion failure in -[_UIFlowLayoutSection computeLayoutInRect:forSection:invalidating:invalidationContext:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3600.7.47/UIFlowLayoutSupport.m:823
2017-09-14 16:03:06.689177-0400 ClientCenterApp[404:48958] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UICollectionViewFlowLayout internal error'

Anyone has an idea why?

1 Answers
Related