iPhone에서 table view 목록에서 왼쪽->오른쪽 또는 오른쪽->왼쪽으로 swipe 하였을 때 삭제가 나오게 하는 UI가 있습니다. 다음과 같이 말이죠.

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewCellEditingStyleDelete;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
// 여기서 항목 삭제
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}tableView:commitEditingStyle:forRowAtIndexPath: 에서 [indexPath row]를 이용하여 table view에 있는 셀의 index (0-based) 값을 얻을 수 있는데, DB에서 삭제한다거나 메모리/파일에서 삭제 하면 됩니다.



Attribution/Share Alike 2.0 license






