【发布时间】:2014-03-26 11:31:40
【问题描述】:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"];
cell.firstLabel.text = [NSString stringWithFormat:@"%d", indexPath.row];
cell.secondLabel.text = [NSString stringWithFormat:@"%d", NUMBER_OF_ROWS - indexPath.row];
return cell;
}
这是来自 Apple Table View Programming Guide 的代码 sn-p
MyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"]; 工作正常,无需检查 nil,因为单元格是在故事板中定义的,并且始终返回有效单元格。
但如果我不使用故事板,我将如何以编程方式在我的表格视图中使用多个自定义单元格?以及涉及到哪些问题allocating and initializing MyTableViewCell
【问题讨论】:
标签: ios objective-c uitableview