我試圖創建一個廈門國際銀行自定義表格視圖單元格,但是當我打電話的時候:崩潰創建自定義的UITableViewCell
CustomReferenceTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
我得到如下:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSObject 0x7aa59c00> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key
這裏是我的設置:
- (void)viewWillAppear:(BOOL)animated
{
[self.tableView registerNib:[UINib nibWithNibName:@"CustomReferenceTableViewCell"
bundle:[NSBundle mainBundle]]
forCellReuseIdentifier:@"referenceCell"];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"referenceCell";
CustomReferenceTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[CustomReferenceTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
cell.number.text = @"1";
cell.referenceName.text = @"Name";
cell.reference.text = @"The text of the reference";
return cell;
}
這是我的連接圖片在inter面對建造者。另外我cellIdentifiers類和廈門國際銀行之間的匹配:
我已經看到了這個帖子here,但我似乎仍不能得到它的工作。
幫助將不勝感激。
編輯
這裏是表示自定義類的設定的照片。下面是我對tableViewCell
初始化器:
這裏是標題:
#import <UIKit/UIKit.h>
@interface CustomReferenceTableViewCell : UITableViewCell
@property (nonatomic, weak) IBOutlet UILabel *number;
@property (nonatomic, weak) IBOutlet UILabel *referenceName;
@property (nonatomic, weak) IBOutlet UILabel *reference;
@end
這裏是實現:
#import "CustomReferenceTableViewCell.h"
@implementation CustomReferenceTableViewCell
- (void)awakeFromNib {
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
請您可以發佈您的代碼CustomReferenceTableViewCell初始化 – pbasdf 2014-10-28 11:10:13
我認爲'參考',''參考名''和'號'都聲明爲屬性在CustomRefernceTableViewCell.h – pbasdf 2014-10-28 11:19:58
是的。他們都是連接在xib上的IBOutlets。 – pls 2014-10-28 11:23:47