2014-11-11 3 views
1

셀을 스 와이프하거나 "편집"버튼을 통해 편집 모드로 들어가서 삭제할 수있는 tableView가 있습니다. 문제는 편집 모드를 올바르게 활성화/비활성화하는 방법을 모르겠습니다. 사용자가 행을 스 와이프하기 시작하자마자 사용 중지되어야하며 행을 '언 스윕'한 후에 활성화해야합니다.사용자가 완전히 스 와이프하여 테이블 뷰 셀을 삭제하지 않은 경우 수정 버튼을 사용/사용 중지하려면 어떻게해야하나요?

현재 editingEtyEditingRowAtIndexPath에서 editStyleForRowAtIndexPath (삭제를 반환 함)를 사용하지 않도록 설정합니다.

문제는 사용자가 스 와이프를 끝내지 않으면 어떻게됩니까? 예를 들어 행을 스 와이프하기 시작하지만 완전히 스 와이프하기 전에 놓습니다 (행이 다시 튀어 나와 삭제 버튼을 숨김). 이 경우 didEndEditingRowAtIndexPath가 호출되지 않습니다. 반 스 와이프 후에 테이블을 편집 할 수 있도록하려면 어떻게해야합니까?

답변

-1

다른 접근법 (종료 또는 설명 : editingStyleForRowAtIndexPath 및 didEndEditingRowAtIndexPath)이 있습니다. 그리고 이것을 구현해야합니다 :

-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
if (editingStyle == UITableViewCellEditingStyleDelete) 
{ 
    // Configure delete action: 
    // First remove the delete data from you data source. 
    Put here you code, like this: 
    [self.theMutableArrayWithDataSourde removeObjectAtIndex:indexPath.row]; 
    // Second remove the cell: 
    [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; 


} 
} 
관련 문제