在UITableViewCell上显示DeleteConfirmation的奇怪行为 [英] Strange behavior of showingDeleteConfirmation on UITableViewCell

查看:226
本文介绍了在UITableViewCell上显示DeleteConfirmation的奇怪行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

A UITableViewCell 有一个 showsDeleteConfirmation 标志,您可以阅读。顾名思义,这允许您知道单元格是否显示删除按钮。此删除按钮有两种显示方式:


  1. 在一行中滑动。

  2. 编辑模式,然后按下行左侧的 - 图标。

我设置了一些日志记录此标志在单元格的 willTransitionToState:中的值。



在示例(1)中, showsDeleteConfirmation YES ,当在整个行中滑动和退出编辑单元格时(通过在滑动后触摸行外部)。



在示例(2)中, showsDeleteConfirmation NO 当触摸 - 图标时, YES 在退出单元格编辑时(再次触摸行外部)。



首先,有人可以确认是这种情况,它不是我的 UITableViewCell 子类的一个怪癖。



为什么会不一致?在我看来,行为(2)更好,因为它描述了在屏幕上的时间 willTransitionToState:被调用。

c>

你试过检查你的逻辑 didTransitionToState:似乎有意义的是,在实例你点击减号按钮将是 NO ,后来一旦动画完成它会改为 YES


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.

这篇关于在UITableViewCell上显示DeleteConfirmation的奇怪行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆