我创建了i uiscrollview,当我运行我的应用程序时,触摸滚动视图但滚动视图不会滚动。 帮我! 想你! 代码为:
for (int i=0; i<imageCounts; i++)
{
GalleryProperty *itemVo = [itemList objectAtIndex:i];
//1 button
UIImageView *imageview = [[UIImageView alloc] initWithFrame:CGRectMake(0,20,320,460)];
UIImage *image = [UIImage imageWithContentsOfFile:itemVo.pic];
[imageview setImage:image];
[scrollView addSubview:imageview ];
[imageView release];
}
答案 0 :(得分:2)
您必须设置内容大小:
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * 3, scrollView.frame.size.height);
答案 1 :(得分:0)
When initializing set scrollView frame size equal to your View Size.
and setContent offset size according to the no of images you're showing in the scrollView.
In your case
UIScrollView *yourScrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 320, 460)];//init scroll view
for (int i=0; i<imageCounts; i++)
{
GalleryProperty *itemVo = [itemList objectAtIndex:i];
//1 button
UIImageView *imageview = [[UIImageView alloc] initWithFrame:CGRectMake(0,20,320,460)];
UIImage *image = [UIImage imageWithContentsOfFile:itemVo.pic];
[imageview setImage:image];
[scrollView addSubview:imageview ];
yourScrollView.contentSize=CGSizeMake(320*i, 460);//set content size here
[imageView release];
}