-1

I create i uiscrollview, when i run my app, touch the scrollview but the scrollview does not scroll. help me! think you! The code as:

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];
}
Developer
  • 6,375
  • 12
  • 58
  • 92
andon
  • 9
  • 4
  • possible duplicate of [UIScrollView not scrolling](http://stackoverflow.com/questions/2824435/uiscrollview-not-scrolling) – Javier Mar 26 '13 at 05:48

2 Answers2

2

You have to set the content size:

scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * 3, scrollView.frame.size.height);
zoul
  • 102,279
  • 44
  • 260
  • 354
Abhishek Bedi
  • 5,205
  • 2
  • 36
  • 62
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];
    }
Prakash
  • 605
  • 6
  • 16