CollectionVIew size for item not sets for zero.It displays wrong size swift || sizeForItemAt return 0 but cell came || UICollectionView sizeForItemAt Called But Not Sized Correctly

Problem:

I had tried to set the size for item zero but it not sets properly.For that it returns sized value.

collectionView(_:layout:sizeForItemAt:)

            let newSize =  myArray.count > 0 ? CGSize(width: width/3, height: width/3) : CGSize(width: 0, height: 0)


return newSize


Solution:


Because in apple they already said that you must have to set the size value

to be non zero.


            let newSize =  myArray.count > 0 ? CGSize(width: width/3, height: width/3) : CGSize(width: 0.5, height: 0.5)


return newSize



Use the above code it will works good.




Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift