프로가 되자.

post search result

swipe와 관련된 글 1개를 찾았습니다.

  1. 2009/08/17 UITableView에서 swipe 시 (드래그 시) delete 하기 (1)

UITableView에서 swipe 시 (드래그 시) delete 하기

iPhone에서 table view 목록에서 왼쪽->오른쪽 또는 오른쪽->왼쪽으로 swipe 하였을 때 삭제가 나오게 하는 UI가 있습니다. 다음과 같이 말이죠.
사용자 삽입 이미지
이 기능을 구현 하려면 UITableViewDelegate, UITableViewDataSource 두 가지 delegate를 구현한 뒤, 다음과 같은 코드를 작성하여 주시면 됩니다.

- (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에서 삭제한다거나 메모리/파일에서 삭제 하면 됩니다.
크리에이티브 커먼즈 라이센스
Creative Commons License
2009/08/17 11:45 2009/08/17 11:45

top

About this post

이 글에는 아직 트랙백이 없고, 댓글이 단 1개 달려있고, , , , 태그가 달려있으며,
2009/08/17 11:45에 작성되었습니다.

◀ recent : [1] : previous ▶

blog information

프로가 되자.
BLOG main image
빗소리를 먹는 사람.
RSS 2.0Tattertools
최근 글 최근 댓글 최근 트랙백
태그 구름사이트 링크