Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Edit Button on Navigation Controller does not enter edit mode

I have a UIToolbar with an edit bar button on it. This is defined as

self.toolbarItems = [NSArray arrayWithObjects:self.editButtonItem,nil];

The edit bar item shows up, and but when i tap it, nothing happens, it does not change to Done and none of the editing controls show up.

I have implemented the following methods as i would like to be able to tap a cell and display a view to edit that cell's value.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (self.editing) {
        NSLog(@"editing ON in didSelect...");
    }else{
        [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
    }
}

- (void)setEditing:(BOOL)editing animated:(BOOL)animate {
    if (editing) {
        NSLog(@"editing ON in setEditing");
    }else {
        NSLog(@"not editing in setEditing");
    }

}

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    return YES;
}

What is causing the edit button to function incorrectly?

Thanks.

like image 470
joec Avatar asked Jul 21 '26 06:07

joec


1 Answers

I think self.editButtonItem is only supposed to work automatically like that in UINavigationControllers, not toolbars. As in self.navigationItem.rightButton = self.editButton;

like image 146
Nimrod Avatar answered Jul 24 '26 01:07

Nimrod



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!