我有一个包含自定义单元格的 xib 文件。我正在尝试访问在customCell.m
.
这是我的代码:
customCell.m
- (void)awakeFromNib
{
self.label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 50, 200)];
[self.label setText:@"This is a label"];
[self.myView addSubview:self.label];
NSLog(@"%f", self.label.frame.size.height); // Results: 200.0000
}
mainViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
customCell *cellVC = [[cutsomCell alloc] init];
NSLog(@"%f, %f", cellVC.label.frame.size.height); // Results: 0.0000
}