다음과 같이 테이블에 커스터마이징 된 셀이 붙어있다
해당 셀을 삭제할 수 있는 기능을 추가해야 한다
특정셀을 미는 액션을 했을때에,
해당 셀을 삭제 할 수 있었으면 한다
=========================================================================
// Controls whether the background is indented while editing. If not implemented, the default is YES. This is unrelated to the indentation level below. This method only applies to grouped style table views.
- (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
// 단위 셀을 밀어서 삭제하기 위해서, 생성한 함수 - 테이블 뷰에서 삭제 버튼을 클릭하면 호출
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
// 데이타 리스트에서 없애기
[dataArray removeObjectAtIndex:[indexPath row]];
// 미리 정의 된 데이터 파일로 아카이브
[NSKeyedArchiver archiveRootObject:dataArray toFile:dataFilePath];
// 화면에서 보이는 것에서 없애기
[pListView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
선택된 셀을, 저장값에서도 삭제하고
화면에서 보여주고 있는 부분에서도 삭제해준다
특정셀을 밀었을 경우 다음과 같이
삭제할 수 있는 환경이 구성이 된다
Delete 버튼을 누르면,
당연히! 해당 셀을 테이블뷰에서 삭제가 된다
'IT > iPhone' 카테고리의 다른 글
ios에서 특정 셀 삭제후, reloadData로 테이블뷰를 다시 그리기 (0) | 2016.11.17 |
---|---|
ios에서 테이블뷰에 셀 커스터마이징하여 위치시키기 (0) | 2016.06.23 |
ios에서 타이머 기능을 추가하기 (0) | 2016.06.15 |
ios에서 에러 발생 - tableView commitEditingStyle: (0) | 2016.05.10 |
ios에서 타이머에 스레드를 사용하는 방법 _ 검색편 (0) | 2016.05.09 |