为什么在awakeFromNib方法中添加子视图会导致它进入infinate循环?应该在哪里添加子视图?感谢。
- (void)awakeFromNib
{
outlineViewController = [[OutlineViewController alloc] initWithNibName:nil bundle:nil];
NSArray *subViews = [leftView subviews];
if ([subViews count] > 0)
{
[[subViews objectAtIndex:0] removeFromSuperview];
}
[leftView addSubview:outlineViewController.view];
}
答案 0 :(得分:0)
也许是由于
outlineViewController = [[OutlineViewController alloc] initWithNibName:nil bundle:nil];
调用initFromCoder然后调用awakeFromNib。如果OutlineViewController是你发布的awakeFromNib的同一个对象就是这样。