2010-05-29 6 views
4

테이블보기가 있고 모든 셀을 재정렬 할 수 있지만 삭제할 수없는 특정 셀이 있습니다. UiTableView를 삭제 모드로 전환하면 왼쪽에 빨간색 '-'버튼이 나타나지 않고 스 와이프 제스처가이 셀의 삭제 버튼을 불러 오지 못하게하고 다른 버튼에서 삭제 버튼을 원하는 경우 . 어떤 아이디어? '-'물론UITableViewCell : 선택적 삭제 허용

// Override to support conditional editing of the table view. 
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { 
    // Return NO if you do not want the specified item to be editable. 
    return YES; 
} 

답변

7
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{ 

    //if we cant delete the object represented at the index path 
    if ([[tableViewObjectsArray objectAtIndex:indexPath.row] canBeDeleted] == NO){ 
     return UITableViewCellEditingStyleNone; 
    } 
    //otherwise allow the deletion 
    else{ 
     return UITableViewCellEditingStyleDelete; 
    } 
} 

이이 빈 공간 잎 버튼이 있어야 할을하지만, 삭제를 허용하지 않습니다

+0

'- (BOOL) tableView : (UITableView *) tableView shouldIndentWhileEditingRowAtIndexPath : (NSIndexPath *) indexPath'를 사용하면 들여 쓰기를 방지 할 수 있습니다. :) – Johanneke

2

구현. 또한 스 와이프 삭제도 허용하지 않습니다.

+0

이렇게하면 셀의 순서가 변경되는 것을 막을 수 있습니다. 삭제를 중지하고 재정렬을 허용하려고합니다. –