我有一个我想要放入UIScrollView的自定义UIView。我使用这段代码:
-(void)viewDidLayoutSubviews{
myView = [[[NSBundle mainBundle]loadNibNamed:@"Case1" owner:self options:nil]objectAtIndex:0];
[_scrollView setContentSize:CGSizeMake(myView.bounds.size.width , myView.bounds.size.height)];
[_scrollView addSubview:myView];
}
我遇到了崩溃:
“因未捕获的异常而终止应用程序'NSInternalInconsistencyException',原因:'在向视图控制器发送-viewDidLayoutSubviews后仍需要自动布局.INFillingHelpViewController的实现需要将-layoutSubviews发送到视图以调用自动布局。'”
你能帮助我吗?
答案 0 :(得分:0)
为什么这样做。尝试这些代码。如果您需要任何帮助,请询问。
UIView *view=[UIView alloc]initWithNibName:@"view" bundle:nil];
[_scrollView setContentSize:CGSizeMake(myView.frame.size.width , myView.frame.size.height)];
[_scrollView addSubview:view];