하나의 UIViewController 에서 두개 이상의 UITableView 를 표현하기
[샘플]
#pragma mark UITableView dataSource
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if(tableView == societyTable) {
return [societyItems count];
} else if(tableView == digitalTable) {
return [digitalItems count];
}
else
return 0;
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell.
if(tableView == societyTable) {
item* obj = (item *)[societyItems objectAtIndex:indexPath.row];
[[cell textLabel] setText:[obj title]];
} else if(tableView == digitalTable) {
item* obj = (item *)[digitalItems objectAtIndex:indexPath.row];
[[cell textLabel] setText:[obj title]];
}
return cell;
}