0
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the specified item to be editable.
    if ([[fetchedResultsController sections] objectAtIndex:indexPath.section] == 0 ) {
        return NO;
    }
    else {
        return YES;
    }
}

这会阻止我的 NSFetchedResultsController 调用类型为 NSFetchedResultsChangeDelete 的 didChangeObject:

- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject 
       atIndexPath:(NSIndexPath *)indexPath 
     forChangeType:(NSFetchedResultsChangeType)type 
      newIndexPath:(NSIndexPath *)newIndexPath {

    switch (type) {
        case NSFetchedResultsChangeInsert:
            [self.tableView  insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath]
                                   withRowAnimation:UITableViewRowAnimationFade]; 
            break;
        case NSFetchedResultsChangeUpdate:
            [self configureCell:(CustomScheduleTableViewCell *)[self.tableView cellForRowAtIndexPath:indexPath]
                    atIndexPath:indexPath];
            break;
        case NSFetchedResultsChangeDelete:
            [self.tableView  deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] 
                                   withRowAnimation:UITableViewRowAnimationFade]; 
            break;
        case NSFetchedResultsChangeMove:
            [self.tableView  deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] 
                                   withRowAnimation:UITableViewRowAnimationFade]; 
            [self.tableView  insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] 
                                   withRowAnimation:UITableViewRowAnimationFade]; 
            break;      
        default:
            break;
    }

}

如何解决此问题,以使用户无法在此部分中滑动删除行。但是我的程序可以来自后台线程吗?

4

1 回答 1

0

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath方法仅用于允许用户交互编辑。如果您不想这样做,请摆脱此方法。

于 2012-05-21T16:54:52.407 回答