How to enlarge UIScrollview Inner Imageview in iOS?

I am new to iOS Development. I know this question has been asked more times, but I didn't get an answer for it. Here I add my image to one UIImageview and then add this UIImageView to the UIScrollView. I am writing the code for this as

 for(index=0; index < [self.imagesa count]; index++)
{
    NSDictionary *dict=[self.imagesa objectAtIndex:index];
    NSString *image=[dict valueForKey:@"link"];
    bigImage=[[UIImageView alloc]init];
    bigImage.userInteractionEnabled=TRUE;
    bigImage.tag=123;
    bigImage.tag=index;
    bigImage.bounds=CGRectMake(0, 0, self.zoomScroll.frame.size.width, self.zoomScroll.frame.size.height);
    bigImage.frame=CGRectMake(index * self.zoomScroll.frame.size.width, 0, self.zoomScroll.frame.size.width, self.zoomScroll.frame.size.height);
    [self.zoomScroll addSubview:bigImage];
    [bigImage setMultipleTouchEnabled:YES];
    [bigImage sd_setImageWithURL:[NSURL URLWithString:image] placeholderImage:[UIImage imageNamed:@"1.png"]];
    [bigImage setUserInteractionEnabled:TRUE];
    [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:[self.objectarray objectAtIndex:index]];
    self.zoomScroll.scrollEnabled=YES;
    self.zoomScroll.clipsToBounds=YES;

      

and I write ViewforzoomInScrollview as

-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return bigImage;
}

      

Here is my Scrollview Contains all the images, but when I zoom in then it only resizes the first image and after scaling the scroll size is set to fixed and it is not scrolling. Here I have set all Property Delegates from Scrollview like MaximumZoomScale, MinimumZoomScale but this is not Zoom Curreent image in Scrollview it Zoom Always the first Imageview image, please give me a solution for this.

+3


source to share


1 answer


This raywenderlich tutorial covers exactly what you want to do.



I assume you should set the min / max zoom level to UIScrollView

0


source







All Articles