UITableView:检测在编辑模式下点击“ - ”按钮 [英] UITableView : detecting click on '-' button in edit mode

查看:138
本文介绍了UITableView:检测在编辑模式下点击“ - ”按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iphone应用程序,我有一个UITableView在编辑模式,包含自定义UITableViewCell。
我想检测用户点击每个单元格的左按钮(减去圆形红色按钮,旋转的动画),就在删除按钮出现之前。

On my iphone app, I have a UITableView in edit mode, containing custom UITableViewCell. I would like to detect when user has clicked on the left button of each cell (minus circular red button, the one that is animated with a rotation), just before the "Delete" button appears.

我想在这种情况下更改我的单元格内容...

I would like to be able to change my cell content in that case...

这是可能吗?

谢谢!

推荐答案

您可以子类 UITableViewCell ,它实现 -willTransitionToState:和/或 -didTransitionToState:方法。

You can subclass UITableViewCell that implements -willTransitionToState: and/or -didTransitionToState: methods.

willTransitionToState: UITableViewCell的子类可以实现此方法,以便在单元格更改状态时。 UITableViewCell每当单元格在状态之间转换时调用此方法,例如从正常状态(默认)到编辑模式。自定义单元格可以设置和定位与新状态一起显示的任何新视图。然后该单元接收layoutSubviews消息(UIView),其中它可以将这些新视图定位在其新状态的最终位置。子类必须在覆盖此方法时始终调用super。

willTransitionToState: Subclasses of UITableViewCell can implement this method to animate additional changes to a cell when it is changing state. UITableViewCell calls this method whenever a cell transitions between states, such as from a normal state (the default) to editing mode. The custom cell can set up and position any new views that appear with the new state. The cell then receives a layoutSubviews message (UIView) in which it can position these new views in their final locations for the new state. Subclasses must always call super when overriding this method.

这篇关于UITableView:检测在编辑模式下点击“ - ”按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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