tableview 사용된 프로젝트
//테이블뷰 섹션의 수
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;
}
//테이블뷰 Row의 갯수
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
//테이블뷰 Row의 높이
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 50;
}
//테이블뷰 섹션 타이틀 지정
- (NSString *) tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger) section {
return @"스텐스";
}
//테이블뷰 섹션의 높이
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 36;
}
//테이블뷰 Footer의 높이
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 39;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
//코드 작성
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
//코드 작성
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
//커스텀 셀 사용
NewsCus *cell = (NewsCus *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
// cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
NSArray *arr = [[NSBundle mainBundle] loadNibNamed:@"NewsCus" owner:nil options:nil];
cell = [arr objectAtIndex:0];
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
DetailArticle *detailViewController = [[DetailArticle alloc] initWithNibName:@"DetailArticle" bundle:nil];
[self.navigationController pushViewController:detailViewController animated:YES];
}
}
테이블뷰 사용시 기본적으로 사용되는 메소드들. 테이블뷰는 가장 흔하게 사용되는 함수로 리스트 형식으로 데이터를 보여줄 때 사용된다.
프로젝트 할때마다 쓰는데.. 테이블뷰의 세계는 끝이 없는 것 같다
'IT > iOS' 카테고리의 다른 글
iOS5 Automatic reference counting (0) | 2012.06.19 |
---|---|
Custom Actionsheet (커스텀 액션쉬트 이미지 넣기) (0) | 2012.06.14 |
앱에서 다른 앱 호출 (0) | 2012.06.13 |
View Animation (뷰 애니메이션) (0) | 2012.06.12 |
Couldn't register com.yourcompany with the bootstrap server. Error: unknown error code. (0) | 2012.05.24 |
UITextView 줄바꿈 (0) | 2012.05.23 |
MAC에서 특수문자(Special Characters) 입력 (0) | 2012.05.23 |
UITableView cell 추가 및 삭제 (0) | 2012.05.23 |