【发布时间】:2016-04-15 09:29:09
【问题描述】:
我在故事板中使用 UIScrollview 并在其中应用自动布局。在 UIScrollview 内,我插入 contentview 作为 UIScrollview 的自动布局需要一个 contentview。现在,根据我的应用场景,我必须更改 contentView 的高度,所以我以编程方式更改了 contentView 的自动布局。
现在我在以编程方式更改自动布局后得到 contentView 的高度 = 445。下面是我的代码
//----set height of content view----//
CGRect contentViewFrame = contentView.frame;
contentViewFrame.size.height= viewMainContent.frame.origin.y+viewMainContent.frame.size.height + 20 ;
contentView.frame = contentViewFrame;
_contentHtConstraint.constant = contentView.frame.size.height;
根据这个UIScrollview 的高度也是445。但是 UIScrollview 的 contentSize 将是 675。
谁能告诉我如何管理 contentSize?
【问题讨论】:
-
你打电话给
[self updateViewConstraints]了吗? -
@zhubch No..我要在哪里打电话?
-
在你改变约束后调用它。
-
@zhubch 没用..仍然有同样的问题
-
@zhubch 在滚动视图的 contentSize 中出现问题不在滚动视图的高度 //----设置内容视图的高度----// CGRect contentViewFrame = contentView.frame; contentViewFrame.size.height= viewMainContent.frame.origin.y +viewMainContent.frame.size.height + 20 ; contentView.frame = contentViewFrame; _contentHtConstraint.constant = contentView.frame.size.height; _objScroll.contentSize = CGSizeZero; [自我更新视图约束];
标签: ios objective-c iphone uiscrollview autolayout