UICollectionView not showing all items

Published

I am develop in Xamarin.iOs using MVVMCross to databind ObservableCollection to a MvxCollectionViewSource and the items are displayed in a UICollectionView. When setting the items to the ObservableCollection not all of them are shown in the UICollectionView. For instance if I set 10 items to the collection view only 7 of them are shown. Any idea why this could happen?

Source: Xamarin.ios Questions

Published
Categorised as Uncategorised Tagged , ,

Answers

I’ve had this same problem ONLY in iOS 8.0 but no in iOS 9.0, and @JordiVilaplana answer gave me a hint about the solution.

The problem seems to be the estimatedItemSize property of UICollectionViewController. Removing that line solved the problem.

In fact, that property is only useful if cells heigh is calculated dynamically, as stated by documentation:

Providing an estimated cell size can improve the performance of the
collection view when the cells adjust their size dynamically.
Specifying an estimate value lets the collection view defer some of
the calculations needed to determine the actual size of its content.
Specifically, cells that are not onscreen are assumed to be the
estimated height.

Otherwise, if your cells are all the same size take the documentation advice:

If all of your cells are the same height, use the itemSize property,
instead of this property, to specify the cell size instead.

And avoid that problem 🙂


Jason Wuckert

Leave a Reply

Your email address will not be published. Required fields are marked *

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq