Ho uno strano problema. Ho creato una classe che eredita da UITableViewCell con un membro UIView.Impossibile accedere alle proprietà del livello di un UIView in UITableViewCell
Nel file di implementazione, voglio accedere alle proprietà del layer di colorView, ma xcode mostra "no completion".
@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 dice "Proprietà 'cornerRadius' non può essere trovato nell'oggetto di classe 'CALayer'". Tuttavia, posso accedere a cornerRadius in un'altra classe.
MTReportPieChartTableViewCell *cell = (MTReportPieChartTableViewCell *) [tableView dequeueReusableCellWithIdentifier:[MTReportPieChartTableViewCell identifier]];
cell.colorView.layer.cornerRadius = 3.0f; // This line works fine!
Perché questo succede! Non ho assolutamente idee su dove ho sbagliato nel codice!
Questo non funziona. self.contentView non ha colorView. –