Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Improving performance for UICollectionView in i...

Improving performance for UICollectionView in iOS10

Slides of my talk at the DO-iOS 2016 conference including optimise drawing processing.

Avatar for Bart den Hollander

Bart den Hollander

November 15, 2016

Other Decks in Technology

Transcript

  1. !

  2. "#

  3. Cell pre-fetching func collectionView(_ collectionView: UICollectionView, prefetchItemsAt indexPaths: [IndexPath]) func

    collectionView(_ collectionView: UICollectionView, cancelPrefetchingForItemsAt indexPaths: [IndexPath]) New in iOS10
  4. Cell pre-fetching class MinionsViewController: UICollectionViewController { override func viewDidLoad() {

    super.viewDidLoad() collectionView.prefetchDataSource = self } } extension MinionsViewController: UICollectionViewDataSourcePrefetching { func collectionView(_ collectionView: UICollectionView, prefetchItemsAt indexPaths: [IndexPath]) { ImagePreloader.preloadImagesForIndexPath(indexPaths) } func collectionView(_ collectionView: UICollectionView, cancelPrefetchingForItemsAt indexPaths: [IndexPath]) { ImagePreloader.cancelPreloadImagesForIndexPath(indexPaths) } } New in iOS10
  5. class MinionsViewController: UICollectionViewController { override func viewDidLoad() { super.viewDidLoad() }

    extension MinionsViewController: UICollectionViewDataSourcePrefetching { func collectionView(_ collectionView: UICollectionView, prefetchItemsAt indexPaths: [IndexPath]) { ImagePreloader.preloadImagesForIndexPath(indexPaths) } func collectionView(_ collectionView: UICollectionView, cancelPrefetchingForItemsAt indexPaths: [IndexPath]) { ImagePreloader.cancelPreloadImagesForIndexPath(indexPaths) } } Cell pre-fetching collectionView.prefetchDataSource = self } New in iOS10
  6. class MinionsViewController: UICollectionViewController { override func viewDidLoad() { super.viewDidLoad() collectionView.prefetchDataSource

    = self } } func collectionView(_ collectionView: UICollectionView, cancelPrefetchingForItemsAt indexPaths: [IndexPath]) { ImagePreloader.cancelPreloadImagesForIndexPath(indexPaths) } } Cell pre-fetching extension MinionsViewController: UICollectionViewDataSourcePrefetching { func collectionView(_ collectionView: UICollectionView, prefetchItemsAt indexPaths: [IndexPath]) { ImagePreloader.preloadImagesForIndexPath(indexPaths) } New in iOS10
  7. func collectionView(_ collectionView: UICollectionView, cancelPrefetchingForItemsAt indexPaths: [IndexPath]) { ImagePreloader.cancelPreloadImagesForIndexPath(indexPaths) }

    class MinionsViewController: UICollectionViewController { override func viewDidLoad() { super.viewDidLoad() collectionView.prefetchDataSource = self } } extension MinionsViewController: UICollectionViewDataSourcePrefetching { func collectionView(_ collectionView: UICollectionView, prefetchItemsAt indexPaths: [IndexPath]) { ImagePreloader.preloadImagesForIndexPath(indexPaths) } } Cell pre-fetching New in iOS10