我有两个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];
我收到错误,“意外的接口名称......预期表达式。”错误。有什么想法吗?
答案 0 :(得分:8)
您需要向Class
发送registerClass:forCellReuseIdentifier:
,因此您需要执行此操作:
[self.tableView registerClass:[ButtonCell class] forCellReuseIdentifier:buttonCellIdentifier];
[self.tableView registerClass:[GameCell class] forCellReuseIdentifier:gameCellIdentifier];
祝你好运!
答案 1 :(得分:1)
没关系,我明白了。我只需要做[ButtonCell类]。