我有一个使用XIB创建的自定义表格视图单元格:
我已经将XIB文件与我的自定义UITableView单元格链接起来。
但是现在,当我尝试在`- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath`中加载单元格时,使用以下代码:
但是现在,当我尝试在`- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath`中加载单元格时,使用以下代码:
MyCustomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
if (cell == nil) {
// Load the top-level objects from the custom cell XIB.
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomTableViewCell" owner:cell options:nil];
// Grab a pointer to the first object (presumably the custom cell, as that's all the XIB should contain).
cell = [topLevelObjects objectAtIndex:1];
}
我遇到了一个错误: [<NSObject 0x8a5b970> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key hitMeButton.
我在网上搜索了一下,可能的原因之一是XIB没有与IBOutlet连接,但我已经检查过了,好像不是这个问题。