3

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.

Ben
  • 2,982
  • 1
  • 16
  • 12
joec
  • 3,533
  • 10
  • 60
  • 89

1 Answers1

2

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

Nimrod
  • 5,168
  • 1
  • 25
  • 39
  • OK, thanks.So i created a separate button. Now my minus buttons appear. Is it possible to detect the taps on the row though? I would like to be able to edit the items in the table view, and currently in editing mode, `didSelectRowAtIndexPath` is not called. Thanks. – joec Oct 13 '10 at 22:58
  • Check out the documentation for UITableViewCell property editingAccessoryType – Nimrod Oct 13 '10 at 23:31