簡體   English   中英

當移動帶有核心數據的UITableView部分的最后一行時 - > NSRangeException

[英]When last row in section of UITableView with Core Data is moved -> NSRangeException

嗨:在我在'controllerDidChangeContent:'中實現'userDrivenChange'檢查后,在Core Data支持的UITableView中各部分之間移動行的工作非常好,如蘋果文檔中所述。 但只有當一個部分的最后一行移動到另一個部分時,我才會得到一個NSRangeException 當部分變空時,顯然存在問題。 我怎么能處理最好的方法呢?

你實現了-controller:didChangeSection:atIndex:forChangeType: method? 如果沒有,那可能看起來像這樣:

-(void)controller:(NSFetchedResultsController *)controller didChangeSection:(id <NSFetchedResultsSectionInfo>)sectionInfo atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type {     
    switch(type) {          
        case NSFetchedResultsChangeInsert:
            [self.tableView insertSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
            break;

        case NSFetchedResultsChangeDelete:
            [self.tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
            break;
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM