Reputation: 164
I'm trying to show a UIButton when the UITableView is in editing mode like this:
- (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];
}
But this doesn't work, do you have any ideas?
Upvotes: 0
Views: 414
Reputation: 1159
- (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");
}
}
Upvotes: 1