0

There is no error log just this what I see.

I have a dynamic prototype UICollectionViewCell, and loading in here:

override func collectionView(collectionView: UICollectionView!, cellForItemAtIndexPath indexPath: NSIndexPath!) -> UICollectionViewCell! {

    var cell: LeftMenuCollectionViewCell

cell = collectionView.dequeueReusableCellWithReuseIdentifier("xxx", forIndexPath: indexPath) as LeftMenuCollectionViewCell // <- at this line something goes wrong

    return cell
}

I am registering class before:

self.collectionView.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: "xxx")

Using iOS 8 beta 5 now

enter image description here

Keenle
  • 12,010
  • 3
  • 37
  • 46
János
  • 32,867
  • 38
  • 193
  • 353

3 Answers3

2

You have registered UICollectionViewCell instead of your own cell class LeftMenuCollectionViewCell. So that the casting of

UICollectionviewCell as LeftMenuCollectionViewCell 

is breaking and causing the crash. To fix this register the proper class

self.collectionView.registerClass(LeftMenuCollectionViewCell.self, forCellWithReuseIdentifier: "xxx")
Anil Varghese
  • 42,757
  • 9
  • 93
  • 110
2

Agree with the two solution below, I registered cell incorrectly, but afterward I found an other issue, cell's outlets become nil. And the solution for that was to remove whole registration, if UICollectionViewController was created via Interface Builder.

Community
  • 1
  • 1
János
  • 32,867
  • 38
  • 193
  • 353
1

You have registered the cell incorrectly. Try this:

self.collectionView.registerClass(LeftMenuCollectionViewCell.self, forCellWithReuseIdentifier: "xxx")
wottle
  • 13,095
  • 4
  • 27
  • 68