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

Posted by 장현준

2009/08/17 11:45 2009/08/17 11:45
, , ,
Response
No Trackback , a comment
RSS :
http://b4you.net/blog/rss/response/241

Trackback URL : http://b4you.net/blog/trackback/241

« Previous : 1 : ... 16 : 17 : 18 : 19 : 20 : 21 : 22 : 23 : 24 : ... 245 : Next »

블로그 이미지

빗소리를 먹는 사람.

- 장현준

Notices

Archives

Authors

  1. 장현준

Recent Trackbacks

  1. 듀얼클러치의 생각 rsvin28's me2DAY 2009

Calendar

«   2012/02   »
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29      

Site Stats

Total hits:
158001
Today:
71
Yesterday:
228