gpt4 book ai didi

ios - 无法注册 UITableViewCell 的自定义子类

转载 作者:可可西里 更新时间:2023-11-01 04:23:47 31 4
gpt4 key购买 nike

我有两个 Xcode 不喜欢的 UITableViewCell 自定义子类。我正在尝试像这样调用 registerClass:forReuseIdentifier: 方法:

static NSString* gameCellIdentifier = @"GameCell";
static NSString* buttonCellIdentifier = @"ButtonCell";
// Register the classes for use.
[self.tableView registerClass:ButtonCell forCellReuseIdentifier:buttonCellIdentifier];
[self.tableView registerClass:GameCell forCellReuseIdentifier:gameCellIdentifier];

我收到错误消息,“意外的接口(interface)名称......而不是预期的表达式。”错误。有什么想法吗?

最佳答案

你需要发送一个 ClassregisterClass:forCellReuseIdentifier: 所以你需要这样做:

[self.tableView registerClass:[ButtonCell class] forCellReuseIdentifier:buttonCellIdentifier];
[self.tableView registerClass:[GameCell class] forCellReuseIdentifier:gameCellIdentifier];

祝你好运!

关于ios - 无法注册 UITableViewCell 的自定义子类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16888459/

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