我正在使用TableView xib,并且所有委托和数据源似乎都正常运行。 如果我设置self.textLabel.text
,它会正确显示正确的tableviews的数量,但我需要显示我的自定义TableViewCell。无法让我的自定义UITableViewCell显示
我创建了一个HistoryCell.xib,其中只有一个tableviewcell。 我创建了一个UITableViewCell类“HistoryCell.h/HistoryCell.m”,它被设置为HistoryCell.xib的文件所有者。 连接了UILabels到HistoryCell.h UILabel statusLabel
UILabel nameLabel
UILabel timeLabel
在我的主视图控制器类int他cellForRowAtIndexPath
我把在
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"historyCellType";
HistoryCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[HistoryCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.nameLabel.text = @"Donald Duck";
return cell;
}
我在做什么错?
谢谢!
你可以看看链接上的教程,但它基本上是@veddermatic回答的。 http://www.icodeblog.com/2009/05/24/custom-uitableviewcell-using-interface-builder/ – CainaSouza 2013-03-21 20:35:14