我有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)名称...期望的表达式”。错误。有任何想法吗?
最佳答案
您需要将Class
发送到registerClass:forCellReuseIdentifier:
,因此您需要执行以下操作:
[self.tableView registerClass:[ButtonCell class] forCellReuseIdentifier:buttonCellIdentifier];
[self.tableView registerClass:[GameCell class] forCellReuseIdentifier:gameCellIdentifier];
祝你好运 !
关于ios - 无法注册UITableViewCell的自定义子类,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16888459/