Since logging this issue I found a solution/workaround by using the systemLayoutSizeFitting(_:withHorizontalFittingPriority:verticalFittingPriority:)
method. It still looks that there is an issue in iOS 13 with systemLayoutSizeFitting
of a UICollectionViewCell
because this method is no longer being called as it is on iOS 13 and lower. Now you have to override the systemLayoutSizeFitting(_:withHorizontalFittingPriority:verticalFittingPriority:) method of an UICollectionViewCell
and use it as you used to use the systemLayoutSizeFitting
.
Code example:
import UIKit
class FlickPhotoCell: UICollectionViewCell {
func getCellSize(_ targetSize: CGSize) -> CGSize {
return CGSize(width: 50, height: 200)
}
// Only this is called on iOS 12 and lower
override func systemLayoutSizeFitting(_ targetSize: CGSize) -> CGSize {
return self.getCellSize(targetSize)
}
// Only this is called on iOS 13 beta
override func systemLayoutSizeFitting(_ targetSize: CGSize, withHorizontalFittingPriority horizontalFittingPriority: UILayoutPriority, verticalFittingPriority: UILayoutPriority) -> CGSize {
return self.getCellSize(targetSize)
}
}
This project illustrates an difference in the way the systemLayoutSizeFitting
of a UICollectionViewCell
is being called when running the same code on iOS 12.1 and iOS 13.0 beta (Xcode version Version 11.0 beta 2 (11M337n)). This leads to the inability to implement a "self-sizing: cells inside a UICollectionView
when running on iOS 13.
Also made a thread in Stackoverflow regarding this issue.
The systemLayoutSizeFitting
is used to implement the so called "self-sizing" cells inside UICollectionView
: