嘿,大家好,我很困惑如何在一个UITableView中使用两个不同的单元格类型和两个部分。第一节应该返回一个大的单元格,其中有很多文本,另一节应该返回三个单元格,以导航到其他视图。我想这样的:两个不同的单元格类型在一个UITableView中
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//NSUInteger section;
static NSString *CellIdentifier1 = @"CellIdentifier";
static NSString *CellIdentifier2 = @"Cell";
if (indexPath.section == 0) {
CustomTableCell *cell = (CustomTableCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier1];
if (cell == nil)
{
[[NSBundle mainBundle] loadNibNamed:@"CustomTableCell" owner:self options:nil]; cell = [self customTableCell];
[self setCustomTableCell:nil];
}
return cell;
}
else if (indexPath.section == 1) {
cTableViewCell *cell = (cTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier2];
if (cell == nil)
{
[[NSBundle mainBundle] loadNibNamed:@"cTableViewCell" owner:self options:nil];
cell = [[cTableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier2];
[self setCustomTableCell:nil];
}
// Configure the cell...
NSUInteger row = [indexPath row];
cell.textLabel.text = [array objectAtIndex:row];
return cell;
}
return cell;
}
我设定的高度在这里的部分细胞:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger section;
if (section == 0) {
return [indexPath row] + 80;
}
else
{
return [indexPath row] + 44;
}
}
我得到这个错误:“细胞”未申报(第一次使用此功能)。 :(我真的希望你能帮助我。提前
你从哪里得到这个错误吗? – pmerino 2011-05-22 18:28:32