在我的 Storyboard的一个 uitableview 中,我定义了一个原型(prototype)单元。在那个单元格(自定义类 kzTexturedCellv2)中,我有一个 TextView 和一个 ImageView 。我还给了单元格一个标识符(“kzTexturedCellv2”)并使用了
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
kzTexturedCellv2 *cell = [[kzTexturedCellv2 alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"kzTexturedCellv2"];
...
创建单元格。问题是单元格显示为空白(没有我在 Storyboard中添加的任何 subview 。)当我尝试在单元格内设置 uitextview 的文本时,它总是返回 null。这里发生了什么?
最佳答案
使用 Storyboard 时,无需分配初始化单元格。
见 dequeueReusableCellWithIdentifier behavior changed for prototype cells?
仅使用:
kzTexturedCellv2 *cell = [tableView dequeueReusableCellWithIdentifier:@"kzTexturedCellv2"];
Alloc init 将由框架处理
关于objective-c - 为什么我的原型(prototype)单元格显示为空白?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10779155/