我知道这个问题被再次问及再次在这里,但没有找到我的problem.I'm通过XIB创建一个自定义的UITableViewCell,并试图解决任何以加载它,在我的VC叫ACSummaryVC创建自定义UITableViewCell?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"SimpleTableCell";
AcSummaryCell *cell = (AcSummaryCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"AcSummaryCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
}
AcSummaryCell是UITableViewCell
一个子类,它有一个UILabel
IBOutlate称为acLabel.when我编译项目我获得以下错误 -
`Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ACSummaryVC 0x71465c0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key acLabel.'`
我创建康恩在AcSummayCell类中的acLabel,但我从ACSummaryVC错误?我做错了什么?
编辑: - 根据摩尼的答案波纹管我连接outlate到文件的所有者,这是错误的,而不是我来outlate连接到定制cell.but当我尝试这方面,我没有得到我的outlate连接相反,我越来越喜欢这个图像 -
现在的问题是如何连接我的outlate自定义单元格? 这里是我的AcSummayCell.h
@interface AcSummayCell : UITableViewCell
@property(nonatomic, retain)IBOutlet UILabel* acLabel;
@property(nonatomic, retain)IBOutlet UILabel* namelbl;
@property(nonatomic, retain)IBOutlet UILabel* cBalancelbl;
@property(nonatomic, retain)IBOutlet UILabel* avBalancelbl;
和AcSummayCell.m
#import "AcSummayCell.h"
@implementation AcSummayCell
@synthesize acLabel = _acLabel;
@synthesize namelbl = _namelbl;
@synthesize cBalancelbl = _cBalancelbl;
@synthesize avBalancelbl = _avBalancelbl;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
您是否将xib中的自定义类设置为ACSummayCell? – karthika
是的,我做过。并尝试删除并重新创建连接/ xib等..但没有运气。 – Bharat
检查一切是否连接良好,或者您的xib文件没有错误的引用。 – Raspu