尝试导入自定义 UITableViewCell,它一直给我一个文件未找到词法预处理器错误。我想不通。
ProductCell.h
#import <UIKit/UIKit.h>
@interface ProductCell : UITableViewCell {
IBOutlet UILabel *descript;
IBOutlet UILabel *productCode;
IBOutlet UIImageView *prodImage;
}
@property (nonatomic, retain) IBOutlet UILabel *descript;
@property (nonatomic, retain) IBOutlet UILabel *productCode;
@property (nonatomic, retain) IBOutlet UIImageView *prodImage;
@end
ProductCell.m
#import "ProductCell.h"
@implementation ProductCell
@synthesize descript;
@synthesize productCode;
@synthesize prodImage;
- (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
在我的 UItableviewcontroller.h 文件中,我尝试导入为 @class
,但似乎没有什么不同。在我的实现文件中,我只是
#import "ProductCell.h"
这是为什么呢?我缺少什么基本步骤。在实现文件中导入它应该可以解决我的问题。尝试清洁项目
最佳答案
将头文件重命名为其他名称并将其重命名回其原始名称确实解决了我的问题。
关于objective-c - 尝试导入自定义 UITableViewCell 一直给我在 Objective-C 中找不到文件的词法预处理器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5098384/