gpt4 book ai didi

ios - UITableViewCell subview 的 IBOutlet 为 (NULL)

转载 作者:行者123 更新时间:2023-12-01 17:40:13 25 4
gpt4 key购买 nike

我在 xib 中定义了一个自定义 UITableViewCell。它的内容 View 中有两个 View ,一个标签 View 和一个 TextView 。

在我的 TableView Controller 中,使用

JJDTextInputCell *cell = [[SDLTextInputCell alloc] init];

或者
JJDTextInputCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TextInputCell" forIndexPath:indexPath];

IBOutlet 为空,因此表格 View 不显示默认文本或我尝试使用的任何文本
cell.descriptionLabel.text = @"foo";

初始化使用界面生成器创建的自定义 UITableView 单元格的正确方法是什么?

最佳答案

AFAIK,有两种方法可以使表格单元格出列,您可以找到它们here在文档中。在 Creating Table View Cells 下找到它们.您正在使用 dequeueReusableCellWithIdentifier:forIndexPath:它总是返回一个有效的单元格但是你需要使用 registerNib:forCellReuseIdentifier:与此成对发挥作用。您必须注册类(class),然后您将获得一个有效的单元格。查看 this问题供引用。

关于ios - UITableViewCell subview 的 IBOutlet 为 (NULL),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22644491/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com