如何检测iPhone UITableView的编辑模式 [英] How to detect edit mode on iPhone UITableView

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

问题描述

对于我的iPhone应用程序,我有一个可编辑(删除)表视图。我想要能够检测到用户已经点击了编辑按钮。查看此图片: http://grab.by/It0

For my iPhone app, I have an editable (for delete) table view. I'd like to be able to detect that the user has clicked the "Edit" button. See this image: http://grab.by/It0

从文档,它看起来像是如果我实现:

From the docs, it looked like if I implemented :

- (void)tableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath

然后我可以检测它(虽然从方法的名称,我不会这样认为)。这证明不工作。

then I could detect it (although from the name of the method, I wouldn't think that). This proved not to work.

有关检测此问题的任何想法吗?我想要的原因是我想在删除模式时在左上角连接一个全部删除按钮。

Any ideas on detecting this? The reason I want to is I want to hook up a "Delete all" button in the upper left hand corner when in delete mode.

感谢

推荐答案

它可能不能正常工作,因为 willBeginEditingRowAtIndexPath:

It is probably not working as you expect because willBeginEditingRowAtIndexPath: is called before the editing starts.

如果您想在另一种方法中检查您需要编辑属性:

If you want to check while in another method you need the editing property:

@property(nonatomic, getter=isEditing) BOOL editing

如果要在按下编辑按钮时执行某些操作,您需要实现setEditing方法:

If you want to do something when the 'Edit' button is pressed you need to implement the setEditing method:

 - (void)setEditing:(BOOL)editing animated:(BOOL)animated

这将在 UIViewController 中找到。 (嗯,这是最可能的地方;有其他人。)

Which you'll find in UIViewController. (Well, that's the most likely place; there are others.)

这篇关于如何检测iPhone UITableView的编辑模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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