我在尝试在 Xcode 4 中为我的 iPhone 应用程序创建自定义 tableview 单元格时遇到问题。我创建了 .h 和 .m 文件,为单元格内应该存在的所有子视图创建了 IBOutlets,然后拖动Interface Builder 中单元格的 XIB 文件中的实际控件。但是,我不知道如何将插座连接到 IB 控件。我阅读的每个教程都说要从对象列表中的 TableViewCell 对象控制拖动到子视图,但是当我这样做时,我的 IBOutlets 不会在弹出窗口中列出。唯一可用的插座是“acccessoryView”、“backgroundView”、“editingAccessoryView”和“backgroundSelectedView”。我不应该也在该列表中看到我自己的 IBOutlets 吗?还是我没有遵循正确的程序?(一世'
这是我用于自定义单元类的代码:
。H :
//
// RecommendationCell.h
// Tuneplug
//
// Created by Bill Labus on 6/21/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface RecommendationCell : UITableViewCell {
UIImageView *artwork;
}
@property (nonatomic, retain) UIImageView *artwork;
@end
.m:
//
// RecommendationCell.m
// Tuneplug
//
// Created by Bill Labus on 6/21/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "RecommendationCell.h"
@implementation RecommendationCell
@synthesize artwork;
- (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
}
- (void)dealloc
{
[super dealloc];
}
@end
(请注意,我现在将子视图简化为“艺术品”图像视图,以简化计算)。谢谢你的帮助!