0

i am newbie in iOS Development i make an Application that contain ScrollView and i add an array images inside scrollview but it is not working.

I write a code for that

for(int index=0; index < [self.imagesa count]; index++)
{
    NSDictionary *dict=[self.imagesa objectAtIndex:index];
    NSString *image=[dict valueForKey:@"link"];
    UIImageView *bigImage=[[UIImageView alloc]init];
    bigImage.bounds=CGRectMake(0, 0, self.zoomScroll.frame.size.width, self.zoomScroll.frame.size.height);
    bigImage.frame=CGRectMake(0, 0, self.zoomScroll.frame.size.width, self.zoomScroll.frame.size.height);
    [bigImage sd_setImageWithURL:[NSURL URLWithString:image] placeholderImage:[UIImage imageNamed:@"1.png"]];
    [self.objectarray insertObject:bigImage atIndex:index];
    CGSize scrollViewSize=CGSizeMake(self.zoomScroll.frame.size.width*[self.objectarray count], self.zoomScroll.frame.size.height);
    [self.zoomScroll setContentSize:scrollViewSize];
    [self.zoomScroll addSubview:bigImage];
    [self.zoomScroll addSubview:[self.objectarray objectAtIndex:index]];
}

it is add my all images in one imageview. not a one by one in Scrollview please give me solution for that

Here object array is NSMutableArray array and imagesa is also NSMutableArray and it is contain image URLlink.

Ashish Gabani
  • 445
  • 1
  • 5
  • 30

1 Answers1

4

See the X co-ordinate of your "bigImage.frame". Your adding images on same co-ordinates, one over the other. It should be...

bigImage.frame=CGRectMake(index * self.zoomScroll.frame.size.width, 0, self.zoomScroll.frame.size.width, self.zoomScroll.frame.size.height);
RoHaN
  • 372
  • 3
  • 14
  • thnx bro but i want a space between images how it possible? – Ashish Gabani Nov 11 '14 at 05:41
  • #RoHaN also i add a UIPanGestureRecognizer and UIPinchGestureRecognizer to my bigimage then it is not working. – Ashish Gabani Nov 11 '14 at 05:48
  • For space just add some overhead to x co-ordinate. Something like 10.0f. "bigImage.frame=CGRectMake(index * self.zoomScroll.frame.size.width + 10.0f, 0, self.zoomScroll.frame.size.width, self.zoomScroll.frame.size.height);" – RoHaN Nov 11 '14 at 06:01
  • Can you show me the code for gesture recognizer, what have u tried. – RoHaN Nov 11 '14 at 06:03
  • now i want to zoom UISCrollView when button is pressed How it is Possible? – Ashish Gabani Nov 11 '14 at 06:05
  • Try [this](http://www.raywenderlich.com/10518/how-to-use-uiscrollview-to-scroll-and-zoom-content). – RoHaN Nov 11 '14 at 06:08
  • Bro when i add a pinch gesture then image was pinched outside of Scrollview how i add pinch only inside of scrollview size? – Ashish Gabani Nov 11 '14 at 06:10
  • add pinch gesture to your image view, [LINK](http://stackoverflow.com/questions/15616210/pinch-gesture-not-working-with-imageview) – RoHaN Nov 11 '14 at 06:20