简体   繁体   中英

Strange behavior of showingDeleteConfirmation on UITableViewCell

A UITableViewCell has a showingDeleteConfirmation flag that you can read. As the name suggests, this allows you to know if the cell is showing the 'delete' button. There are two ways this delete button can be displayed:

  1. Swiping across a row.
  2. Entering edit mode for the cell and then pressing the '-' icon on the left of the row.

I set up some logging to check the value of this flag in the cell's willTransitionToState: . And I found something that confuses me.

In example (1), showingDeleteConfirmation is YES both when swiping across the row and when exiting editing for the cell (by touching outside the row after the swipe).

In example (2), showingDeleteConfirmation is NO when touching the '-' icon, but YES when exiting editing for the cell (again by touching outside the row).

First, can someone confirm this is the case, and that it is not a quirk of my UITableViewCell subclass.

Why would this be inconsistent? In my opinion behavior (2) is better, since it describes what is on screen at the time willTransitionToState: is called.

Have you tried checking your logic in didTransitionToState: instead? It seems to make sense that at the instance you tap the minus button it would be NO and that later once the animation has finished it would change to YES .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM