【发布时间】:2013-12-06 17:48:57
【问题描述】:
我正在开发一个 iOS 应用程序,我正在尝试将图像动态地放入滚动视图中。
我声明了滚动视图并将图像放入其中。图像显示在正确的位置,但滚动视图不滚动。
这是我的代码:
imagesScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0,screenWidth,screenHeight];
for (int i =0; i<dim; i++) { //dim is the number of the images to show
NSData * data = [NSData dataWithContentsOfURL:[NSURL URLWithString:previewImage_URL]];
previewImages = [UIImage imageWithData:data];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,10+(200*i),screenWidth,200)];
[imageView setImage:previewImages];
[imagesScrollView addSubview:imageView];
}
我该怎么做?
【问题讨论】:
-
您从未设置滚动视图的内容大小,因此它不知道它需要滚动。之后,如果您仍然遇到问题,您可以在图像视图上将用户交互设置为 no。
标签: ios scrollview