我有一个UIView/UIViewController (UIViewController
)在storyboard中包含一个自定义的UIView (CustomView
),它有一个相关的。xib文件。当我加载UIViewController
时,我遇到以下现象:
-
CustomView
的awakeFromNib
函数称为 - SOMETHING(?)设置子视图的帧高度为0.0;堆栈跟踪显示
[UIViewController autoresizedArchivedView]
(相关?) -
UIViewController
的viewDidLoad
函数称为
知道awakeFromNib
和viewDidLoad
之间发生了什么,我该如何控制它吗?
在 viewDidLoad:
之后才对存档对象设置几何属性 - (void)viewDidLoad
{
[super viewDidLoad];
NSLog (@"%@ %@",
NSStringFromSelector(_cmd),
NSStringFromCGRect(self.testView.frame));
}
- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
NSLog (@"%@ %@",
NSStringFromSelector(_cmd),
NSStringFromCGRect(self.testView.frame));
}
- (void) viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
NSLog (@"%@ %@",
NSStringFromSelector(_cmd),
NSStringFromCGRect(self.testView.frame));
}
日志: viewDidLoad {{0, 0}, {0, 0}}
viewWillAppear: {{0, 0}, {0, 0}}
viewDidAppear: {{80, 224}, {160, 274}}