【发布时间】:2015-11-17 05:00:59
【问题描述】:
我为我的ViewController设置了以下约束
然后我添加这样的自定义视图。
-(void)setUI
{
int i;
for ( i=0; i<[array count]; i++)
{
NSLog(@"Object at index %i %@",i,[array objectAtIndex:i]);
UIView *view=[self GetAlertView:i];
float sizeOfContent = 0;
if (notY+view.frame.size.height>self.contentView.frame.size.height+self.contentView.frame.origin.y) {
CGRect frame=self.contentView.frame;
frame.size.height=notY;
self.contentView.frame=frame;
}
[self.contentView addSubview:view];
self.mainScroll.contentSize = self.contentView.frame.size;
NSLog(@"CONTENT VIEW FRAME HEIGHT==== %f",self.contentView.frame.origin.y+self.contentView.frame.size.height);
}
}
但我的问题是这个内容视图不会永久增加它的大小。在 log cat 中,我可以看到高度正在变化。
CONTENT VIEW FRAME HEIGHT==== 8913.000000
但这不是坚持。在 UI 中,我可以看到它的高度只是保持一定的高度,并且只有 3 个子视图添加到内容视图中,其他视图不在内容视图中。这是什么原因?请帮我 谢谢
【问题讨论】:
-
我认为将这一行从 for 循环 self.mainScroll.contentSize = total height 中取出并将其更改为上述行并在 for 循环之后调用 [self.view layoutsubviews] 方法。
标签: ios objective-c uiview uiscrollview ios-autolayout