У меня странная проблема. Я создал класс, наследующий от UITableViewCell с членом UIView.Не удается получить доступ к свойствам слоя UIView в UITableViewCell
@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. –