2012-11-14 64 views
0

我試圖展現一個UIButton當UITableView的是在這樣的編輯模式:顯示一個UIButton時的UITableView處於編輯模式

- (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]; 
} 

但是,這並不工作,你有什麼想法?

+0

嘗試使用是或否? – Omarj

+0

我已經試過這些。 – tchike

+0

[tableView setEditing:YES animated:YES]; – Omarj

回答

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"); 
    } 
} 
相關問題