Allowing users to delete cells

Any good contacts app enables users to remove contacts. The previous version of Hello-Contacts used a swipe gesture on a table view cell to delete a cell. Swiping a cell made a button appear that the user could tap and the corresponding UITableViewDelegate method was called.

Unfortunately, UICollectionViewDelegate does not specify a similar delegate method for deleting cells. This means that you'll need to do a little more work to implement cell deletion for a collection view. A very simple implementation would be to have the user long-press on a cell, ask them whether they want to delete the contact, and reload the collection view if needed. This would work but the deleted contact would quickly disappear, and ...

Get Mastering iOS 12 Programming - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.