Strange behavior of showingDeleteConfirmation on UITableViewCell

雨燕双飞 提交于 2020-01-04 06:52:05

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/12945771/strange-behavior-of-showingdeleteconfirmation-on-uitableviewcell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!