ren*_*ooi 0 xcode objective-c ios
我为一个tablecell做了一个自定义视图,我在单元格中有一些元素,我编写了正确的IBOutlet conenctions等等.
当我不进行任何IBOutlet连接时,我会看到我制作的自定义单元格,所以类和引用都很好.
我建立一个元素的连接,然后编译我得到:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<SearchViewController 0x1d05f0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key image.'
Run Code Online (Sandbox Code Playgroud)
.h文件...再次,没有连接它工作(但我不能修改自定义单元格的整个想法的元素)我连接到IBOutlet后得到此错误...
我也尝试逐个连接,但它们都在同一范围内给出错误
CustomTableCell.h
#import <UIKit/UIKit.h>
@interface CustomTableCell : UITableViewCell
{
IBOutlet UIImageView *image;
IBOutlet UILabel *labelHeader;
IBOutlet UILabel *labelDescription;
IBOutlet UIButton *labelButtonPrice;
IBOutlet UIButton *labelButtonSize;
IBOutlet UIButton *labelButtonFloor;
IBOutlet UIButton *labelButtonBeds;
IBOutlet UIButton *labelButtonBaths;
}
@property (nonatomic) IBOutlet UIImageView *image;
@property (nonatomic) IBOutlet UILabel *labelHeader;
@property (nonatomic) IBOutlet UILabel *labelDescription;
@property (nonatomic) IBOutlet UIButton *labelButtonPrice;
@property (nonatomic) IBOutlet UIButton *labelButtonSize;
@property (nonatomic) IBOutlet UIButton *labelButtonFloor;
@property (nonatomic) IBOutlet UIButton *labelButtonBeds;
@property (nonatomic) IBOutlet UIButton *labelButtonBaths;
@end
Run Code Online (Sandbox Code Playgroud)
CustomTableCell.m
#import "CustomTableCell.h"
@implementation CustomTableCell
@synthesize image;
@synthesize labelHeader;
@synthesize labelDescription;
@synthesize labelButtonPrice;
@synthesize labelButtonSize;
@synthesize labelButtonFloor;
@synthesize labelButtonBeds;
@synthesize labelButtonBaths;
- (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];
}
@end
Run Code Online (Sandbox Code Playgroud)
来自搜索表的tableview
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CustomTableCellIdentifier = @"CustomTableCell";
CustomTableCell *cell = (CustomTableCell *)[tableView dequeueReusableCellWithIdentifier:CustomTableCellIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCell_iPhone" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
//cell.nameLabel.text = [tableData objectAtIndex:indexPath.row];
//cell.thumbnailImageView.image = [UIImage imageNamed:[thumbnails objectAtIndex:indexPath.row]];
//cell.prepTimeLabel.text = [prepTime objectAtIndex:indexPath.row];
return cell;
}
Run Code Online (Sandbox Code Playgroud)
现在,当我根本没有连接时,我会看到自定义单元格,当我建立连接时它会停止.
将自定义单元格放在xib文件中并将IBOutlet连接到"文件所有者"对象而不是单元格本身时,可能会发生此问题.
然后,当您尝试使用视图控制器作为xib的文件所有者从xib加载单元时,它会尝试连接image到控制器的不存在的属性.
尝试检查插座连接并确保它们仅连接到您的电池,而不是任何其他物体
| 归档时间: |
|
| 查看次数: |
1718 次 |
| 最近记录: |