2013-08-09 4 views
1

enter image description here tagListTableView를 새로 고침하고 싶습니다.UITableview 셀 삭제. 하지만 deosn't reload cell

하지만 새로 고침하지 않습니다.

UITableview 셀의 삭제 버튼을 탭하면 coraData의 날짜에있는 객체를 제거 할 수 있습니다.

그러나 테이블보기에서 셀을 삭제해도 화면에는 여전히 비어있게됩니다.

viewWillAppear, viewDidAppear ..... [tagListTableView reloadData]를 시도했습니다.

무엇이 부족합니까 ?? 당신이있는 tableview, 당신은 뭘하고 있었 재 장전 이후를 다시로드하기 전에

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { 
    return UITableViewCellEditingStyleDelete; 
} 

- (void)tableView:(UITableView *)tableView 
      commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 
      forRowAtIndexPath:(NSIndexPath *)indexPath { 
    if (editingStyle == UITableViewCellEditingStyleDelete) { 
     Voca_Tag *tag = (Voca_Tag *)[self.fetchedResultsController objectAtIndexPath:indexPath]; 
     UITableViewCell *cell = [tagListTableView cellForRowAtIndexPath:indexPath]; 
     [cell setSelected:NO animated:YES]; 

     [tag.managedObjectContext deleteObject:[self.fetchedResultsController objectAtIndexPath:indexPath]]; //  [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES]; 
     [tagListTableView reloadData]; 

     [pickedTags removeObject:tag]; 
     cell.accessoryType = UITableViewCellAccessoryNone; 

     NSError *error = nil; 
     if (![tag.managedObjectContext save:&error]) { 
      NSLog(@"Unresolved error %@, %@", error, [error userInfo]); 
      abort(); 
     } 
    } 
} 

- (BOOL)tableView:(UITableView *)tableView 
     canEditRowAtIndexPath:(NSIndexPath *)indexPath { 
    return YES; 
} 

답변

0
if (editingStyle == UITableViewCellEditingStyleDelete) { 
     Voca_Tag *tag = (Voca_Tag *)[self.fetchedResultsController objectAtIndexPath:indexPath]; 
     UITableViewCell *cell = [tagListTableView cellForRowAtIndexPath:indexPath]; 
     [cell setSelected:NO animated:YES]; 

     [tag.managedObjectContext deleteObject:[self.fetchedResultsController objectAtIndexPath:indexPath]]; //  [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES]; 


     //******** 
     //REMOVE the object before reloading the table 
     [pickedTags removeObject:tag]; 

     [tagListTableView reloadData]; 


     cell.accessoryType = UITableViewCellAccessoryNone; 

     NSError *error = nil; 
     if (![tag.managedObjectContext save:&error]) { 
      NSLog(@"Unresolved error %@, %@", error, [error userInfo]); 
      abort(); 
     } 
    } 

당신은 당신의 pickedTags에서 개체를 제거해야합니다.

도움이 될만한 정보가 있습니다.

+0

나는 이미 시도했다. 그것은 같은 결과였다. –