Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

171
Vistas
Does setting estimatedItemSize on UICollectionViewFlowLayout break UICollectionViewDataSourcePrefetching?

I am creating a UICollectionView with cells of dynamic height and using estimatedItemSize property on UICollectionViewFlowLayout (Apple Docs Reference).

Although, I noticed that once I set the estimatedItemSize property, my prefetchItemsAt method for UICollectionViewDataSourcePrefetching delegate is not getting called.

func collectionView(_ collectionView: UICollectionView, prefetchItemsAt indexPaths: [IndexPath])

If I don't set estimatedItemSize, prefetching starts working again. Is this known behavior or am I doing something wrong here? Please help.

Sample Code:

class CollectionViewController: UICollectionViewController {

var layout: UICollectionViewFlowLayout = {
    let layout = UICollectionViewFlowLayout()
    let width = UIScreen.main.bounds.size.width
    layout.estimatedItemSize = CGSize(width: width, height: 100)
    return layout
}()

override func viewDidLoad() {
    super.viewDidLoad()
    if #available(iOS 10.0, *) {
        collectionView?.prefetchDataSource = self
    }

    collectionView.collectionViewLayout = layout

    // Register cell classes
    self.collectionView.register(UINib.init(nibName: "CollectionViewCell", bundle: nil), forCellWithReuseIdentifier: reuseIdentifier)
}
}

extension CollectionViewController: UICollectionViewDataSourcePrefetching {

// MARK: UICollectionViewDataSourcePrefetching
func collectionView(_ collectionView: UICollectionView, prefetchItemsAt indexPaths: [IndexPath]) {


    // Fetch more cells
    print("prefetchItemsAt called.")
}
}
over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda