小编Tej*_*han的帖子

如何将自定义 UITableViewCell 添加到 xib 文件中

我想在视图控制器中为 tableviewcell 加载我的自定义 xib。我无法在 tableview 中加载我的 xib

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    CustomCell *cell = (CustomCell *)[tableView  dequeueReusableCellWithIdentifier:[CustomCell reuseIdentifier]];
    if (cell == nil) {
           [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
           cell = _customCell;
           _customCell = nil;
    }        

    cell.topLabel.text = @"I am on top";
    cell.bottomLabel.text = @"and I'm on the bottom";

    return cell;     
}
Run Code Online (Sandbox Code Playgroud)

我无法将我的自定义单元格从 xib 加载到 tableview 中。请帮我。

objective-c tableview ios

0
推荐指数
1
解决办法
4762
查看次数

标签 统计

ios ×1

objective-c ×1

tableview ×1