-2

Tableviewcontrollerで使用される2つのTableviewVertical1を作成しているアプリケーションがあり、各セクションに1つの行があり、内部に別のHorizo​​ntal Tableviewを作成しました。「PASSWORDViewController」にManagedObjectを追加すると、 ManagedObjectは正しく保存されますが、NSFetchedResultsChangeInsertがtableviewcontrollerで呼び出されると、水平ではなく垂直のテーブルビューを使用して更新されます。

私は何かが欠けていますが、それを理解することはできません、何か助けはありますか?

4

2 に答える 2

0

実際には、以下のコードのNSFetchresultschangeinsert:

- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject
       atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type
      newIndexPath:(NSIndexPath *)newIndexPath
{
    HorizontalTableCell *fuck=[[HorizontalTableCell alloc]init];
    UITableView *tableView= fuck.horizontalTableView;
    //UITableView *tableView = self.tableView;
    //newIndexPath.section==indexPath.section;
    //NSLog(@"The Type of the Fetched %d",i);

    switch(type) {
        case NSFetchedResultsChangeInsert:

            [tableView insertRowsAtIndexPaths:@[newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
            break;

        case NSFetchedResultsChangeDelete:
            [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
            break;

        case NSFetchedResultsChangeUpdate:
            [self configureCell:[tableView cellForRowAtIndexPath:indexPath] atIndexPath:indexPath];
            break;

        case NSFetchedResultsChangeMove:
            [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
            [tableView insertRowsAtIndexPaths:@[newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
            break;
    }
}

このコードは、デフォルトでApple Default CoreData、UItableViewControllerにあります

于 2012-09-13T18:57:54.433 に答える
0

MainViewControllerでFetchリクエストを実行し、それをNSMutableArrayに渡してから、他のテーブルビューで使用し、変更を行い、次にNSManagedObjectContextを実行し、MainViewControllerに通知を送信して、テーブルビューデータを再度読み込むことで、この問題を解決しました。

于 2012-11-05T11:50:03.297 に答える