fetchedResultsController가 지원하는 테이블 뷰가 있습니다. 내 테이블 셀에는 뷰가 걱정되는 한 소프트 삭제를 수행하는 버튼이 있습니다 ... 버튼을 탭하고 소프트 삭제를 수행하는 선택기가 호출되며 ... 무언가가 발생해야합니다. 내가 많은 시도를 해봤지만) 애플의 행 애니메이션과 같은 애니메이션을 시도하지 않았다.Core Data/UITableView에서 데이터 새로 고침 (소프트 삭제)
길을 벗어난 슬라이드 만들기와 같이 간단한 행 애니메이션을 수행 할 수 있습니다. 테이블을 다시로드하라는 메시지가 나올 때까지 빈 행을 남겨 둡니다. 이는 약간의 반항 효과입니다. 이것은 내가 왔어요 가장 가까운 :
-(void) completeTask: (id) sender { NSIndexPath *indexPath = [self.tableView indexPathForCell:(UITableViewCell *)[[sender superview] superview]]; NSDate *date = [[NSDate alloc] init]; NSManagedObject *task = [self.fetchedResultsController objectAtIndexPath:indexPath]; [task setValue:date forKey:@"complete"]; AppController *ac = [AppController sharedAppController]; NSManagedObjectContext *moc = [ac managedObjectContext]; NSError *error = nil; if(![moc save:&error]){ NSLog(@"%@ %@",error, [error description]); exit(-1); } else { UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; CGRect cellFrame = cell.frame; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.35]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(someAnimationDidStop:finished:context:)]; cell.frame = CGRectMake(cellFrame.size.width , cellFrame.origin.y, cellFrame.size.width, cellFrame.size.height); [UIView commitAnimations]; } } -(void) someAnimationDidStop:(NSString *)animationID finished:(BOOL)finished context:(void *)duration { NSLog(@"Animation Stopped"); [self fetchResults]; // this guy performs a new fetch and table data reload }
내가 바른 길에 일종의 것 같은 내가 그러나 나는이 정말 꽤 대답은 생각하지 않는다 생각합니다. 나는 어떻게 든 controller:didChangeObject:atIndexPath:forChangeType:newIndexPath:
가 응답이되기를 바랐다. 내 생각 엔 재고가있는 Apple 애니메이션을 원한다면 결과를 추적하고 동기화 상태를 유지하기 위해 별도의 NSMutableArray를 만들어야합니다.
생각과 의견?
감사합니다 !!!
맞습니다 - 실제 삭제를 올바르게 사용하기 위해 대리인 메서드를 일부 변경 한 후 수동 테이블 관리를 제거 할 때까지 아래의 내 대답이 작동하지 않는 것으로 나타납니다. 감사! – Cameron