본문 바로가기

개발도구/iOS - 아이폰 개발

[ios] tableview DataSource Delegate

 DataSource Methods (9개)

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
 : 표현할 데이터의 총 Section의 갯수. (2차원 배열의 경우)

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
 : 표현할 데이터에서 하나의 Section에 있는 총 Row의 갯수. (1차원배열의 경우엔 Section이 아닌 Array에 들어있는 총 Object의 갯수)

- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
 : Section의 헤더 

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
 : Section의 풋터 

- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
 :  

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
 : 실제 하나의 셀마다에 값을 넣어주는 부분 

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
 : 삽입/삭제를 이용할지 안할지를 정의하는 부분 

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
 : Row의 이동을 허용할지 안할지를 정의하는 부분 

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
 : 테이블뷰의 삽입/삭제 작업 후에 호출 됨

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
 : 테이블뷰의 이동작업 후에 호출 됨 




Delegate Methods (21개)

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
 : Footer 높이 

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
 : Header 높이 

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
 : Row 높이 
 

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
 : DataSource의 String형 헤더가 아닌 커스팀가능한 TableView Footer를 만들 때 사용 

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section

 : DataSource의 String형 헤더가 아닌 커스팀가능한 TableView Header를 만들 때 사용
 

- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
 : 테이블뷰의 Row를 클릭했을 때 호출 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 : tableView:willSelectRowAtIndexPath가 호출 된 후 호출
 

- (NSIndexPath *)tableView:(UITableView *)tableView willDeselectRowAtIndexPath:(NSIndexPath *)indexPath
 : 테이블뷰의 선택을 해지할 때 호출 

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
 : tableView:WillDeselectRowAtIndexPath가 호출 된 후 호출
 

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
 : TableView Cell의 오른쪽에 붙는 AccessoryButton을 클릭했을 때 호출 

- (UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath
 : Accessory의 종류를 변경할 때 사용
 

- (void)tableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath
 : 테이블뷰의 수정을 시작할 때 호출 

- (void)tableView:(UITableView *)tableView didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath
 : 테이블뷰의 수정을 종료할 때 호출
 
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
 : 테이블뷰의 EditStyle(삽입/삭제)에 대해서 정의할 때 사용 

- (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath
 : 테이블뷰가 edit상태 일 때 Cell의 앞쪽에 들여쓰기를 사용할지 안할지를 정의할 때 사용 

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
 : 테이블뷰가 다 구성되고 사용자에게 보여지기 직전에 마지막으로 호출되는 메소드 


- (BOOL)tableView:(UITableView *)tableView canPerformAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender

- (void)tableView:(UITableView *)tableView performAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender


- (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath

- (NSIndexPath *)tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath

- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath 


참고링크 http://j2enty.com/82