0

当 UITableView 处于编辑模式时,我试图显示一个 UIButton,如下所示:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

    if (editingStyle == UITableViewCellEditingStyleDelete) {
    NSLog(@"deleting :%i", indexPath.row);

        // Delete the managed object for the given index path
        NSManagedObjectContext *context = [fetchedResultsController managedObjectContext];
        [context deleteObject:[fetchedResultsController objectAtIndexPath:indexPath]];

        self.buttonAdd.hidden = FALSE;

        // Save the context.
        NSError *error = nil;
        if (![context save:&error]) {
            NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
            exit(-1);
        }
    }
[self.table reloadData];
}

但这不起作用,您有什么想法吗?

4

1 回答 1

1
- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
    // Make sure you call super first
    [super setEditing:editing animated:animated];

    if (editing)
    {
         do your code
      //  self.editButtonItem.title = NSLocalizedString(@"Cancel", @"Cancel");
    }
    else
    {
              do your code
       // self.editButtonItem.title = NSLocalizedString(@"Edit", @"Edit");
    }
}
于 2012-11-14T20:35:32.030 回答