Why is my UITableViewController setEditing: an animated method not being called?

I have to do stupid things, but I don’t see that: my subclass is UITableViewControllernever called when the edit button of my navigation is pressed.

What could be the reason for this?

My view hierarchy is loaded from a Nib file and placed inside a popover. The [+] button is connected to the action of insertNewObjectmy subclass UITableViewController. It works great.

The [Change] button, however, has no action to connect. The document says that it will automatically call the setEditing:animated:view controller method , which I override.

The nib file is configured almost like a regular AFAICT. And in fact, I'm not sure what additional details I can give that will offer my mistake.

What is a control flow from clicking the [Edit] button to calling a method setEditing:animated?

+3
source share
1 answer

I feel like we should be missing the same thing.

In any case, I did this by following these steps.

IBOutlet UIBarButtonItem *editButton;

-(IBAction)editButtonPressed:(id)sender {
    [self setEditing:YES animated:YES];
}

- (void)setEditing:(BOOL)editing animated:(BOOL)animate
{
    if(self.tableView.isEditing)
    {
        self.editButton.style = UIBarButtonItemStylePlain;
        self.editButton.title = @"Edit";
    }
    else
    {
        //self.editButton.style = UIBarButtonSystemItemDone;
        self.editButton.style = UIBarButtonSystemItemEdit;
        self.editButton.title = @"Done";
    }

    // Toggle table view state
    [super setEditing:!self.tableView.isEditing animated:animate];
}

I hooked up editButton to the button that I added to the navigation bar, and this is the action for editButtonPressed IBAction. After that, my setEditing: is called (obviously), and the super call switches the editing state of the table view.

, , , , , , "" "", ( , "" ). , () ..

0

Source: https://habr.com/ru/post/1763360/


All Articles