Ios 在UITableview中自定义单个单元格

Ios 在UITableview中自定义单个单元格,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我想更改我的UITableView(masterViewController)中第一个单元格的格式,以便图像横跨整个单元格的宽度,文本标签显示在图像上方。是否只想在此单元格中添加第二个文本标签 关于如何做到这一点的任何帮助都将是非常好的,对于这个特定的问题,我一直没有找到成功的答案,而且我对UITableViews非常陌生。您应该构建一个自定义单元格(可以在Interface builder中构建),然后在indexPath.row==0上使用它。像这样: static NSString *Ce

我想更改我的
UITableView
(masterViewController)中第一个
单元格的格式,以便
图像
横跨整个
单元格的
宽度
,文本标签显示在图像上方。是否只想在此
单元格中添加第二个文本标签


关于如何做到这一点的任何帮助都将是非常好的,对于这个特定的问题,我一直没有找到成功的答案,而且我对
UITableViews

非常陌生。您应该构建一个自定义单元格(可以在Interface builder中构建),然后在
indexPath.row==0
上使用它。像这样:

static NSString *CellIdentifier = @"CellIdentifier";
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(!cell)
{
    NSArray *topLevel = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:nil options:nil];
    for (id currentObject in topLevel){
        if ([currentObject isKindOfClass:[CustomCell class]])
        {
            cell = currentObject;
            break;
        }
    }
}

if(indexPath.row == 0){
    // Use your cell here
}else{
   // Build a new cell
}

return cell;

根据需要制作一个自定义单元格,并为所有其他单元格加载
indexpath.row==0
和simple
UITableViewCell
。希望对你有帮助

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"CustomCell";

CustomCell *customcell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

static NSString * identifier = @"Cell";
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];


if(indexPath.row == k)
{
    if(customcell == nil)
    {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
        scrlcell = [nib objectAtIndex:0];
    }
}
else{
   if(cell == nil){
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
}
}

if(indexPath.row == k)
    return customcell;
else
    return cell;
}

CustomCell用于indexpath.row==0
并将普通单元格或其他单元格用于下一行请使用CustomCell:。如果您没有tableheader。。为什么不自定义tableHeader?还应该使用第二个标识符。我该如何实际实现这一点?在我的cellForRowAtIndexPath中?我添加了这个,但它不识别CustomCell?在故事板中,我需要做些什么来标识名称或其他什么吗?@burrgg make xib for CustomCell。并将您的单元格标识符指定给
CustomCell