iphone - 如何在uitableview iphone sdk的cell.contentview上添加 View

标签 iphone uitableview

在我的应用程序中,我正在创建一个类的 .xib 并将该 .xib 加载到另一个类的 uitableview 的单元格上。我想将此 .xib 添加到 cell.contentView 而不是单元格。我该怎么做?

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

testTableCell * cell = (testTableCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
    [[NSBundle mainBundle] loadNibNamed:@"testTableCell" owner:self options:nil];
    cell = tCell;
}

return cell;
}

testTableCell 是我的另一个类,其中有两个标签和两个按钮,我创建了一个 .xib 并将其加载到上面的 tableview 单元格中。 tCell 是 testTableCell 类的对象。

这真的很紧急。 有人可以帮忙吗? 提前致谢。

最佳答案

好吧,如果您询问如何将自定义单元格添加到 UITableView 中,而不是使用默认的 UITableViewCell,那么这并不是很困难。只需按照以下教程中描述的所有步骤操作即可:

Creating Custom UITableViewCell using Interface Builder

关于iphone - 如何在uitableview iphone sdk的cell.contentview上添加 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2801098/

相关文章:

ios - UITable,如何在 Swift IOS 中将委托(delegate)分配给 UITable

iphone - UITableView contentOffSet 无法正常工作

ios - 约束不能正常工作

iphone - dequeueReusableCellWithIdentifier、自定义 UITableViewCell 的问题

iphone - 如何处理 iOS 的系统警报消息?

iphone - 带缩放 mapView 的点触摸

ios - 一次选择多个 UITextView

iPhone - 捕获设备按钮推送

swift - (Swift) 核心数据移动行 - 无效更新错误

iphone - tableView单元格高度...如何自定义它?