objective-c - 为什么我的原型(prototype)单元格显示为空白?

标签 objective-c ios xcode uistoryboard

在我的 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/

相关文章:

ios - @property (nonatomic,retain) UISegmentedControl *colorChooser 中的警告;

ios - 下载时播放 Mp4 和 Mp3 文件

ios - Swift 或 Objective C 中的垂直 View 寻呼机

ios - 向后滚动

ios - 无法从动态通知 Controller 发送 Watch Connectivity 消息

iphone - 对数组中的日期进行排序

ios - 检测点击 UIImageView IOS

ios - Xcode.embeddedframework

ios - 在 xcode 6 中排序文档大纲

ios - Stripe STPAddCardViewController 导航栏不显示