ios 10 NSfetchedResultController在删除多行时不进行动画处理

嗨,我正在使用CoreData和NSfetchedResultController的应用程序。 删除多行时,我遇到了一个奇怪的问题。 删除动画与IOS 9一起正常工作但是当来到IOS 10.现在有动画(单元格只消失,无论选择什么动画)。

这里是我的fetchedResultController(来自Master-detail模板)

// MARK: - Fetched results controller var fetchedResultsController: NSFetchedResultsController { if _fetchedResultsController != nil { return _fetchedResultsController! } let fetchRequest: NSFetchRequest = Event.fetchRequest() // Set the batch size to a suitable number. fetchRequest.fetchBatchSize = 20 // Edit the sort key as appropriate. let sortDescriptor = NSSortDescriptor(key: "timestamp", ascending: false) fetchRequest.sortDescriptors = [sortDescriptor] // Edit the section name key path and cache name if appropriate. // nil for section name key path means "no sections". let aFetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.managedObjectContext!, sectionNameKeyPath: nil, cacheName: "Master") aFetchedResultsController.delegate = self _fetchedResultsController = aFetchedResultsController do { try _fetchedResultsController!.performFetch() } catch { // Replace this implementation with code to handle the error appropriately. // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. let nserror = error as NSError fatalError("Unresolved error \(nserror), \(nserror.userInfo)") } return _fetchedResultsController! } var _fetchedResultsController: NSFetchedResultsController? = nil func controllerWillChangeContent(_ controller: NSFetchedResultsController) { self.tableView.beginUpdates() } func controller(_ controller: NSFetchedResultsController, didChange sectionInfo: NSFetchedResultsSectionInfo, atSectionIndex sectionIndex: Int, for type: NSFetchedResultsChangeType) { switch type { case .insert: self.tableView.insertSections(IndexSet(integer: sectionIndex), with: .fade) case .delete: self.tableView.deleteSections(IndexSet(integer: sectionIndex), with: .fade) default: return } } func controller(_ controller: NSFetchedResultsController, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) { switch type { case .insert: tableView.insertRows(at: [newIndexPath!], with: .fade) tableView.scrollToRow(at: newIndexPath!, at: .none, animated: true) case .delete: tableView.deleteRows(at: [indexPath!], with: .right) case .update: self.configureCell(tableView.cellForRow(at: indexPath!)!, withEvent: anObject as! Event) case .move: tableView.moveRow(at: indexPath!, to: newIndexPath!) } } func controllerDidChangeContent(_ controller: NSFetchedResultsController) { self.tableView.endUpdates() } 

我的删除function:

 func deleteObjects(_ sender: Any?) { NSLog("test") let context = self.fetchedResultsController.managedObjectContext if (tableView.indexPathsForSelectedRows != nil) { let alert = UIAlertController(title: "Confirm delete?", message: "are your sure?", preferredStyle: .alert) alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { okAction in for selectedIndex in self.tableView.indexPathsForSelectedRows! { context.delete(self.fetchedResultsController.object(at: selectedIndex)) } do { try context.save() } catch { // Replace this implementation with code to handle the error appropriately. // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. let nserror = error as NSError fatalError("Unresolved error \(nserror), \(nserror.userInfo)") } })) alert.addAction(UIAlertAction(title: "No", style: .cancel, handler: nil)) self.present(alert, animated: true, completion: nil) }else{ let alert = UIAlertController(title: "Select rows to delete", message: "please select at least a row", preferredStyle: .alert) alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil)) self.present(alert, animated: true, completion: nil) } 

无论如何要在IOS 10上带回动画? anyhelp非常感激。 谢谢!