为什么我的原型单元格显示为空白? [英] Why do my prototype cells show up blank?

查看:78
本文介绍了为什么我的原型单元格显示为空白?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的故事板的 uitableview 中,我定义了一个原型单元格.在那个单元格(一个自定义类 kzTexturedCellv2)中,我有一个文本视图和一个图像视图.我还给单元格一个标识符(kzTexturedCellv2")并使用

In a uitableview in my storyboard, I have defined a prototype cell. In that cell (a custom class kzTexturedCellv2) I have a text view and an image view. I have also given the cell an identifier ("kzTexturedCellv2") and used

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

kzTexturedCellv2 *cell = [[kzTexturedCellv2 alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"kzTexturedCellv2"];

...

创建单元格.问题是单元格显示为空白(没有我在故事板中添加的任何子视图.)当我尝试在单元格内设置 uitextview 的文本时,它总是返回 null.这是怎么回事?

to create the cells. The problem is that the cells show up blank (without any of the subviews that I added in storyboad.) When I try to set text of the uitextview inside the cell, it always returns null. What is going on here?

推荐答案

使用故事板时,无需分配初始化单元.

When using storyboards there is no need to alloc init the cell.

看到 dequeueReusableCellWithIdentifier 行为改变为原型单元?

仅使用:

kzTexturedCellv2 *cell = [tableView dequeueReusableCellWithIdentifier:@"kzTexturedCellv2"];

Alloc init 将由框架处理

Alloc init will be handled by the framework

这篇关于为什么我的原型单元格显示为空白?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆