iPhone,用于编辑/完成按钮的钩子在表格视图中单击 [英] iPhone, hook for edit/done button click in table view

查看:126
本文介绍了iPhone,用于编辑/完成按钮的钩子在表格视图中单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的表视图控制器中有

In my table view controller there is

self.navigationItem.leftBarButtonItem = self.editButtonItem;

,它会在左上角生成一个常规的编辑/完成按钮。因此,一旦用户单击编辑,按钮标题将更改为完成,并且可以删除或重新排序表条目。我想在用户实际点击完成后收到通知。是否有钩子?

which produces a regular edit/done button at the top left corner. Hence, once the user clicks "Edit", the button caption changes to "Done" and the table entries may be deleted or reordered. I would like to get notified once the user actually clicks "Done". Is there a hook for that?

背景:我想坚持条目的顺序,即下次用户提起这个视图我想呈现最近最少使用的订单中的条目。

Background: I'd like to persist the order of the entries i.e. next time the user pulls up this view I'd like to present the entries in the least recently used order.

推荐答案

对于那些仍然在这个问题上感兴趣的人(或回答:P)

for those who are still interesed in this question (or answer :P)

UITableView API

显示有 - (void)setEditing:(BOOL)编辑动画:(BOOL)animate 方法
每次按下这个编辑/完成按钮时都会调用这些方法。你必须简单地通过(BOOL)编辑参数进行检查。最后但并非最不重要的是,您必须从最初的编辑/完成按钮调用正确的方法。

revealed that there is a - (void)setEditing:(BOOL)editing animated:(BOOL)animate method these method is called every time this edit/done button is pressed. you have to simply check by the (BOOL)editing parameter wich one was used. last but not least you have to call the proper method from the originally edit/done button.

只需将此方法添加到您的uitableview类

simply add this method to your uitableview class

- (void)setEditing:(BOOL)editing animated:(BOOL)animate
{
    [super setEditing:editing animated:animate];
    if(editing)
    {
        NSLog(@"editMode on");
    }
    else
    {
        NSLog(@"Done leave editmode");
    }
}

这篇关于iPhone,用于编辑/完成按钮的钩子在表格视图中单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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