我制作了一个iPhone应用程序,其中包含以下层次结构:。当我尝试滚动我的滚动视图时,它不会滚动。我在项目中使用了自动布局。
即使我的滚动视图的内容大小大于其高度,它仍然不会滚动。以下是我在
即使我的滚动视图的内容大小大于其高度,它仍然不会滚动。以下是我在
viewDidLoad
中编写的代码片段。 UIView *tempo = (UIView *)[scrollVw viewWithTag:6];//View which is inside Scrollview
float sizeOfContent = 0;
for (int i = 0; i < [tempo.subviews count]; i++) {
UIView *view =[tempo.subviews objectAtIndex:i];
sizeOfContent += view.frame.size.height;
}
NSLog(@"sizeOfContent = %f", sizeOfContent);
scrollVw.contentSize = CGSizeMake(scrollVw.frame.size.width, 1500);
NSLog(@"scrollVw width = %f -- scrollVw height =%f",scrollVw.frame.size.width, scrollVw.frame.size.height);
NSLog(@"tempo width = %f -- tempo height =%f",tempo.frame.size.width, tempo.frame.size.height);
日志结果:
sizeOfContent = 1500
scrollVw width = 320.000000 scrollVw height = 416.000000
tempo width = 320.000000 tempo height = 416.000000
我哪里犯了错误?