【发布时间】:2013-11-22 13:50:33
【问题描述】:
我有带有动态原型单元格的 tableview 的 uitableviewcontroller,甚至我将单元格样式更改为字幕或其他内容,或者我添加了附件,我的单元格始终显示为基本样式单元格。
这是我的 cellForRowAtIndexPath 函数:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSInteger row = indexPath.row;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (_dataArray && row < self.dataArray.count) {
cell.textLabel.text = self.dataArray[row];
}
return cell;
}
编辑:有些东西我不明白,也许有人可以解释一下。早些时候,当我显示我的表格视图控制器时,我的应用程序崩溃了,所以我不得不将它添加到 viewDidLoad 方法中:
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:CellIdentifier];
之后应用程序没有崩溃,但导致我无法更改单元格样式。现在我可以删除它,我的应用程序不会崩溃,我可以更改单元格样式。为什么?
我做错了什么?
【问题讨论】:
标签: ios uitableview storyboard