title: Why does a UICollectionView not set isSelected to false for a cell that has isSelected set to true in cellForItemAt?
body: <p>I'm working with a <code>UICollectionView</code> with the default selection rules (single selection only). In my custom <code>UICollectionViewCell</code> class, I've overridden <code>isSelected</code> like so:</p>
  
  <pre><code>override var isSelected: Bool {
      didSet {
          self.backgroundColor = isSelected ? UIColor.gray : UIColor.white
      }
  }
  </code></pre>
  
  <p>I also set <code>isSelected</code> for one specific cell in my view controller's <code>collection​View(_:​cell​For​Item​At:​)</code> because, for some reason, the collection's <code>selectItem()</code> method doesn't work in <code>cellForItemAt</code>.</p>
  
  <p>This has allowed me to make sure that this one cell is selected and has its background changed before the entire view with the collection in it actually appears, but it's produced a weird problem.</p>
  
  <p>When I start tapping other collection cells and selecting them, that one cell I set as selected from the start doesn't have its background color set to white.</p>
  
  <p>However, as I proceed with selecting different cells in sequence by tapping them, the switching of their background colors to white happens just as intended, all the while that one cell where I set <code>isSelected</code> during the collection's initial population remains gray unless I specifically tap it and then tap away from it in a different cell.</p>
  
  <p>Can anyone help me figure out why this is? Why isn't <code>isSelected</code> being set to <code>false</code> when I tap a cell other than the one whose <code>isSelected</code> property I set in <code>cellForItemAt</code>?</p>
  
  <p><strong>Edit:</strong> I tried implementing <code>collection​View:​did​Deselect​Item​At​Index​Path:​</code>, and it simply doesn't trigger. So on one hand, the <code>isSelected</code> property is definitely set, since the background for that one cell changes to gray, but on the other hand, <strong>the collection doesn't seem to perceive that cell as selected</strong>.</p>