Beginning Collection Views - Part 11: Section 1: | Ray Wenderlich

Wrap up this section by reviewing what you've learned about Collection Views, and find out what's coming up in the Section 2.

This is a companion discussion topic for the original entry at

There is one problem that I can’t seem to resolve. If you tap on some cells to mark them as deleted, and then tap on Done without deleting them, the next time you go in to Edit mode. one or more of those cells will show as selected for deletion. Very strange.

I had the same problem. It is caused by UIImageView of that cell kept the checked checkmark image when you select the cell on runtime.
I solved this by changing the UIImage of the UIImageView back to unchecked when the edit mode is false. This is under the collectionCellView class.

var isEditing: Bool = false {
        didSet {
            checkmark.isHidden = !isEditing
            checkmark.image = UIImage(named: "uncheck")

That does not work consistently either. Also, if you tap Done with some items still checked, the toolbar does not get hidden.

Here is a gif showing multiple issues


@catie Can you please help with this when you get a chance? Thank you - much appreciated! :]

I thought you could add the following code to setEditing(_:animated:) and it would work but indexPathsForSelectedItems does not return all the selected items in the setEditing method (try printing the count). always returns 1 item for me.

    collectionView.indexPathsForSelectedItems?.forEach({ (index) in
        collectionView.deselectItem(at: index, animated: true)

@catie Do you have any feedback regarding this? Thank you - much appreciated! :]