I'm trying to build a collection view in a standard view controller via storyboarding. I'm not using a collection view controller because I want several collection views on one screen. The view controller has the right class (statisticsViewController) and the Collection View is connected to the code (as outlet, dataSource and delegate)
My class code is following:
import UIKit
class statisticsViewController :
UICollectionViewController,
UICollectionViewDelegateFlowLayout {
@IBOutlet weak var collectionViewActive: UICollectionView!
private let reuseIdentifier = "cellIdentifier"
var items: [String] = ["Bli", "Bla", "Blubb", "Bla", "Blubb", "Bla", "Blubb", "Bla", "Blubb", "Bla", "Blubb", "Bla", "Blubb"]
override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
return items.count
}
override func viewDidLoad() {
super.viewDidLoad()
println("ich war hier")
}
override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.items.count;
}
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as UICollectionViewCell
cell.backgroundColor = UIColor.blackColor()
return cell
}
}
When I try to run the code I get following error message:
2014-12-18 16:31:47.533 project[2008:92664] *** Assertion failure in -[project.statisticsViewController loadView], /SourceCache/UIKit_Sim/UIKit-3318.16.14/UICollectionViewController.m:166
2014-12-18 16:31:47.536 project[2008:92664] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UICollectionViewController loadView] loaded the "UIr-oH-mfu-view-fG7-sl-ulu" nib but didn't get a UICollectionView.'
*** First throw call stack:
....
When I set a break point I see that viewDidLoad isn't even called.
Does someone has an idea? Thank you for any help :)