iPhone, hook for edit/done button click in table view

后端 未结 4 1585
说谎
说谎 2021-02-01 17:54

In my table view controller there is

self.navigationItem.leftBarButtonItem = self.editButtonItem;

which produces a regular edit/done button at

4条回答
  •  日久生厌
    2021-02-01 18:22

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

    UITableView API

    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.

    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");
        }
    }
    

提交回复
热议问题