이상한 문제가 있습니다. UIView 멤버를 사용하여 UITableViewCell에서 상속하는 클래스를 만들었습니다.UITableViewCell에서 UIView의 레이어 속성에 액세스 할 수 없습니다.
@interface MTReportPieChartTableViewCell : UITableViewCell {
UIView *_colorView;
}
@property (nonatomic, retain) IBOutlet UIView *colorView;
@end
구현 파일에서 레이어의 colorView 속성에 액세스하려고하지만 xcode에 "완료하지 않음"이 표시됩니다.
@implementation MTReportPieChartTableViewCell
@synthesize colorView = _colorView;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.colorView.layer.cornerRadius = 3.0f; // Error occurs in this line
}
return self;
}
@end
xcode는 "속성 'cornerRadius'는 (는) 정방향 클래스 개체 'CALayer'에서 찾을 수 없다고 말합니다." 그러나 다른 클래스의 cornerRadius에 액세스 할 수 있습니다.
MTReportPieChartTableViewCell *cell = (MTReportPieChartTableViewCell *) [tableView dequeueReusableCellWithIdentifier:[MTReportPieChartTableViewCell identifier]];
cell.colorView.layer.cornerRadius = 3.0f; // This line works fine!
왜 이런 일이 발생합니까? 나는 코드에서 잘못한 아이디어가 전혀 없다!
이것은 작동하지 않습니다. self.contentView에는 colorView가 없습니다. –