Bha*_*rat 0 objective-c uitableview ios
我知道这个问题在这里一次又一次地被问到,但没有找到任何解决我的问题的方法.我正在通过xib创建一个自定义UITableViewCell并尝试加载它.在我的VC中称为ACSummaryVC
- (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];
}
}
Run Code Online (Sandbox Code Playgroud)
AcSummaryCell是一个子类,UITableViewCell
它有一个UILabel
名为acLabel 的IBOutlate.当我编译项目时,我得到以下错误 -
`Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ACSummaryVC 0x71465c0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key acLabel.'`
Run Code Online (Sandbox Code Playgroud)
我在AcSummayCell类中创建了acLabel的连接,但我从ACSummaryVC收到错误?我做错了什么?
编辑: -根据Mani的答案,我正在连接到文件所有者,这是错误的而是我要连接到自定义单元格.但是当我尝试这个我没有得到我的支出连接而不是我得到喜欢这张图片 -
现在的问题是如何将我的支出与自定义单元格连接? 这是我的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;
Run Code Online (Sandbox Code Playgroud)
和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
Run Code Online (Sandbox Code Playgroud)
您设置了错误的插座连接.这是因为您已将标签的插座连接到文件的所有者.从文件所有者中删除该标签插座连接,并连接指向自定义单元的插座.它应该工作.
归档时间: |
|
查看次数: |
1185 次 |
最近记录: |