UITableView 를 사용하다 보면 항상 기본적인 delegate와 datasource의 소스들을 다른 소스에서 긁어서 쓰고 있다.
이참에 항상 쓰는 소스만 정리해서 올려 놓으려고 한다.
#pragma mark -
#pragma mark tableview delegate
// 섹션의 갯수
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
// 각 섹션당 로우의 갯수
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return 5;
}
// 각 셀 그리기
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"CalendarCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
return cell;
}
// 셀이 선택 되었을때 수행할 내용
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}
// 각셀의 높이
-(CGFloat) tableView : (UITableView *) tableView heightForRowAtIndexPath : (NSIndexPath *)indexPath{
return 45;
}
반응형
'2013 이전 > iOS개발' 카테고리의 다른 글
| [iOS 개발] iCloud keyValue Data Storage 사용 (0) | 2017.02.25 |
|---|---|
| [iOS 개발] 간단한 animation 처리 (0) | 2017.02.25 |
| [iOS 개발] iCloud app 연동 설정 (0) | 2017.02.25 |
| [iOS 개발] NSArray 역순으로 변환 (0) | 2017.02.25 |
| [iPhone 개발] string 이 URL 형식인지 확인하기 (0) | 2017.02.25 |