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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.