This is driving me crazy! I have a UICollectionViewController as shown below:
class PhrasesCompactCollectionViewController: UICollectionViewController
The numberOfSections and cellForItemAt are being called but the sizeForItemAtIndexPath is never called. I am using the same exact code somewhere else and it fires correctly. I am using Xcode 8 Beta 6.
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize { return CGSize(width: 120, height:120) }
The appearance of each item in the list can be defined by setting the ItemTemplate property to a DataTemplate. By default, a CollectionView will display its items in a vertical list. However, vertical and horizontal lists and grids can be specified. By default, CollectionView selection is disabled.
By default, a CollectionView will display its items in a vertical list. However, vertical and horizontal lists and grids can be specified. By default, CollectionView selection is disabled. However, single and multiple selection can be enabled.
The CollectionView is a flexible and performant view for presenting lists of data using different layout specifications. A CollectionView is populated with data by setting its ItemsSource property to any collection that implements IEnumerable.
However, vertical and horizontal lists and grids can be specified. By default, CollectionView selection is disabled. However, single and multiple selection can be enabled. In CollectionView, an empty view can be specified that provides feedback to the user when no data is available for display.
You need to specify that you implement the protocol UICollectionViewDelegateFlowLayout
in your class declaration.
class PhrasesCompactCollectionViewController: UICollectionViewController, UICollectionViewDelegateFlowLayout
I had the same problem. The one thing that helped me was to make the 'Estimated Size' for the Cell Size under the collectionView size inspector 'None'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With