title: UICollectionView reloadData not working
body: <p>Its getting called in <code>viewDidLoad</code>, after fetching the data used. 
  After some print debugging it looks like it calls all the appropriate delegeate methods, if no data is changed. If there has been some data changed, <code>cellForItemAt</code> does not get called. </p>
  
  <p>Reloading the whole section works fine. But gives me an unwanted animation. Tried disabling <code>UIView</code> animation before, and enabling after reloading section, but still gives me a little animation.</p>
  
  <pre><code>collectionView.reloadSections(IndexSet(integer: 0)) 
  </code></pre>
  
  <p>Here is my current situation, when using reloadData()</p>
  
  <p>The UICollectionViewController is a part of a TabBarController. 
  I'm using custom UICollectionViewCells. The data is loaded from CoreData.</p>
  
  <p>First time opening the tab, its works fine. 
  After updating the favorites item in another tab, and returning to this collectionView, its not updated. But if i select another tab, and go back to this one, its updated.</p>
  
  <pre><code>var favorites = [Item]()
  
  
  override func viewWillAppear(_ animated: Bool) {
  
      collectionView!.register(UINib.init(nibName: reuseIdentifier, bundle: nil), forCellWithReuseIdentifier: reuseIdentifier)
  
      if let flowLayout = collectionView!.collectionViewLayout as? UICollectionViewFlowLayout {
          flowLayout.estimatedItemSize = CGSize(width: 1,height: 1)
      }
  
      loadFavorites()
  
  }
  
  
  func loadFavorites() {
  
      do {
          print("Load Favorites")
  
          let fetch: NSFetchRequest = Item.fetchRequest()
          let predicate = NSPredicate(format: "favorite == %@", NSNumber(value: true))
          fetch.predicate = predicate
          favorites = try managedObjectContext.fetch(fetch)
  
          if favorites.count &gt; 0 {
              print("Favorites count: \(favorites.count)")
              notification?.removeFromSuperview()
          } else {
              showEmptyFavoritesNotification()
          }
  
          print("Reload CollectionView")
  
          collectionView!.reloadData(
  
  
      } catch {
          print("Fetching Sections from Core Data failed")
      }
  }
  
  
  override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
  
      print("Get number of section, \(favorites.count)")
      if favorites.count &gt; 0 {
          return favorites.count
      } else {
          return 0
      }
  }
  
  override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
      print("Get cell")
  
      let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath) as! SubMenuCell
  
      let menuItem = favorites[indexPath.row]
  
      cell.title = menuItem.title
      cell.subtitle = menuItem.subtitle
  
      return cell
  }
  </code></pre>
  
  <p><strong>Console Print/Log</strong></p>
  
  <p><strong>Starting the app, going to the CollectionView tab where there are no favorites:</strong> </p>
  
  <pre><code>Load Favorites
  Get number of section, 0
  Get number of section, 0
  Reload CollectionView
  Get number of section, 0
  </code></pre>
  
  <p><strong>Switching tab, and adding and setting an Item object's favorite to true, then heading back to the CollectionView tab:</strong></p>
  
  <pre><code>Load Favorites
  Favorites count: 1
  Reload CollectionView
  Get number of section, 1
  
  The datamodel has 1 item, reloading CollectonView, cellForRowAtIndex not called?
  </code></pre>
  
  <p><strong>Selecting another tab, random which, then heading back to the CollectionView tab, without changing any data.</strong></p>
  
  <pre><code>Load Favorites
  Favorites count: 1
  Reload CollectionView
  Get number of section, 1
  Get cell
  </code></pre>
  
  <p>Now my Item shows up in the list. You can see from the Get Cell that <code>cellForItemAt</code> is called aswell. Nothing has changed between these last two loggings, just clicked back/fourth on the tabs one time.</p>
  
  <p>Forgot to mention, but this code IS working fine in the simulator. 
  On a read device its just not giving me any error, just not showing the cell (or calling the <code>cellForItemAt</code>)</p>