【发布时间】:2014-06-30 23:13:01
【问题描述】:
我正在使用 TableView xib,所有代表和数据源似乎都运行良好。
如果我设置self.textLabel.text,它会正确显示表格视图的通用数量,但我需要显示我的自定义 TableViewCell。
我创建了一个 HistoryCell.xib,其中只有一个 tableviewcell。
我创建了一个 UITableViewCell 类“HistoryCell.h/HistoryCell.m”,并将其设置为 HistoryCell.xib 的文件所有者。
我将 UILabels 连接到 HistoryCell.h
UILabel statusLabel
UILabel nameLabel
UILabel timeLabel
在我的主 ViewController 类中,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 回答的。 icodeblog.com/2009/05/24/…
标签: ios objective-c uitableview