Swift – when do we need to use 'leastNormalMagnitude', 'leastNonzeroMagnitude'

Advertisements I am developing a collection view, In some cases, to avoid runtime exceptions, I need to return my collection view size to a least minimum size. So that the view takes a minimum space which is too small to view. Here is the code snippet I tried but I am getting an Ambiguous use… Read More Swift – when do we need to use 'leastNormalMagnitude', 'leastNonzeroMagnitude'

CollectionView Cell order messes up on scroll

Advertisements I’m trying to alternate the color of my collection view cells like this: But when I scroll down and then scroll back up, all the cells get reordered like this: This is my code: func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return 100 } } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath:… Read More CollectionView Cell order messes up on scroll

NSInternalInconsistencyException error from collectionView in swift

Advertisements Hi I have two different cell(it may be 6-7 in the future) I return them by some case in cellForItem method of collection view but I got this error(the cell returned from -collectionView:cellForItemAtIndexPath: does not have a reuseIdentifier – cells must be retrieved by calling) Here is my codes. func collectionView(_ collectionView: UICollectionView, cellForItemAt… Read More NSInternalInconsistencyException error from collectionView in swift

UICollectionView not displaying, cellForItemAt and numberOfItemsInSection not called

Advertisements I’m trying to make an app which will display a popup with of devices with "right" or "left" names depending on whether left or right button was pressed. However, after I press left or right button, the popup appears with empty CollectionView. I colored it green to make sure that it’s size is not… Read More UICollectionView not displaying, cellForItemAt and numberOfItemsInSection not called