Exc_arithmetic error with simulator only, destination UICollectionView flowlayout

I am trying to assign UICollectionViewFlowLayout a UICollectionView and it works fine on the physical device, but the simulators will break with the signal:

EXC_ARITHMETIC (code = EXC_i386_DIV, subcode = 0x0)

This only happens on the simulator, I understand that this is usually a division error by 0, but I do not see how this is possible for my implementation

Code:

 let flowLayout: UICollectionViewFlowLayout = UICollectionViewFlowLayout() flowLayout.itemSize = CGSizeMake(self.view.bounds.width * 0.67, self.collectionView!.frame.height - 10) flowLayout.scrollDirection = UICollectionViewScrollDirection.Horizontal self.collectionView!.collectionViewLayout = flowLayout 

In addition, I get a signal in this line: self.collectionView!.collectionViewLayout = flowLayout

View boundaries: WIDTH: 277.38 HEIGHT: 75.0

Any help or alternatives would be greatly appreciated!

+5
source share
2 answers

I had the same problem with the old code I'm working on, and it seems like I'm calling this code from the wrong method. I moved it to a more appropriate place, viewDidLoad or init, and it works.

+3
source

Helped call

reloadData p>

before

setCollectionViewLayout

+2
source

All Articles