cellForItemAt indexPath
n'appelle pas si j'utilise UICollectionViewDelegateFlowLayout
.cellForItemAt IndexPath n'appelle pas si j'utilise UICollectionViewDelegateFlowLayout. Est-ce un bug d'iOS?
Dans ce cas:
class Something: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource {
}
il appelle mon cellforItemAtIndexPath
, mais ne remet pas mon
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
}
mais si j'inclus UICollectionViewDelegateFlowLayout
:
class Something: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
}
il appellera:
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
}
mais n'appelle pas cellForItemAtIndexPath
. Je ne comprends pas le problème. Est-ce un bug d'iOS ou je ne vois rien?
Votre classe n'est pas conforme aux 'UICollectionViewDataSource' et' UICollectionViewDelegate', bien que les fonctions soient toujours appelées. De plus, votre 'cellForRow' ne sera pas appelé si votre' numberOfItems' renvoie 0. – Rikh
try class Quelque chose: UIViewController, UICollectionViewDelegateFlowLayout, UICollectionViewDelegate, UICollectionViewDataSource. –
Je les utilise déjà, je ne les ai pas inclus pour faire paraître mon code court :) @RamkrishnaSharma –