title: Zoom image and then scroll image to view next image, previous image not zooming out
body: <p>I want to zoom out image to original size after scroll slider.
  I'm using <strong>REPagedScrollView</strong> library to implement slider.
  I have 5 images in slider. Now zoom-in 1st image and then immediately scroll slider to view 2nd image. Then go back to view 1st image. 1st image not zooming out. That image was still in zoom - in mode.
  How can i solved this.</p>
  
  <p>Thanks in advance.</p>
  
  <p>I'm using this below code.</p>
  
  <pre><code>-(void)slideShow
  {
      [scrollView removeFromSuperview];
      scrollView = [[REPagedScrollView alloc] initWithFrame:self.scrollVw.bounds];
      scrollView.delegate=self;
      scrollView.pageControl.pageIndicatorTintColor=[UIColor clearColor];
      scrollView.pageControl.currentPageIndicatorTintColor=[UIColor clearColor];
      current_page=0;
  
      for(int i=0;i&lt;[self.PhotoImgArr count];i++){
  
  
          // Image view
          image_scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0,self.scrollVw.frame.size.width,self.scrollVw.frame.size.height)];
          self.image_view = [[AsyncImageView alloc] initWithFrame:CGRectMake(0,0, image_scroll.frame.size.width, image_scroll.frame.size.height)];
  
          self.image_view.backgroundColor=[UIColor clearColor];
       //   self.image_view.contentMode = UIViewContentModeScaleAspectFit;
          self.image_view.clipsToBounds = true;
          self.image_view.userInteractionEnabled = YES;
  
          //self.image_view.image=[UIImage imageNamed:@"Stars"];
          self.image_view.imageURL =[NSURL URLWithString:[self.PhotoImgArr objectAtIndex:i]];
          doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)];
          [doubleTap setNumberOfTapsRequired:2];
  
          [self.image_view addGestureRecognizer:doubleTap];
  //        twoFingerPinch = [[UIPinchGestureRecognizer alloc]
  //                          initWithTarget:self
  //                          action:@selector(twoFingerPinch:)];
  //        [self.image_view addGestureRecognizer:twoFingerPinch];
          [image_scroll setDelegate:self];
          [image_scroll setShowsHorizontalScrollIndicator:NO];
          [image_scroll setShowsVerticalScrollIndicator:NO];
  
          image_scroll.tag=i+1;
          // image_scroll.backgroundColor=[UIColor purpleColor];
          image_scroll.autoresizingMask=UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
          self.image_view.autoresizingMask=UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
  
          image_scroll.contentSize = CGSizeMake(self.image_view.bounds.size.width-500, self.image_view.bounds.size.height-300);
          image_scroll.decelerationRate = UIScrollViewDecelerationRateFast;
          [image_scroll setMaximumZoomScale:4.0];
         // image_scroll.minimumZoomScale = 1.0;
          [image_scroll setZoomScale:[image_scroll minimumZoomScale]];
          //image_scroll.zoomScale = 1.0;
          [image_scroll addSubview:self.image_view];
  
          [scrollView addPage:image_scroll];
  
      }
      scrollView.autoresizingMask=UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
      scrollView.tag=0;
      [self.scrollVw addSubview:scrollView];
  
      [scrollView scrollToPageWithIndex:self.selected_index animated:YES];
  }
  
  - (void)twoFingerPinch:(UIPinchGestureRecognizer *)recognizer
  {
      NSLog(@"twoFingerPinch");
      float newScale = [image_scroll zoomScale] / 2.0;
      CGRect zoomRect = [self zoomRectForScale:newScale withCenter:[recognizer locationInView:recognizer.view]];
      [image_scroll zoomToRect:zoomRect animated:YES];
  }
  
  - (void)handleDoubleTap:(UIGestureRecognizer *)gestureRecognizer {
      // zoom in
      NSLog(@"handleDoubleTap");
       UIScrollView *imageScroll = (UIScrollView *)[self.view viewWithTag:self.selected_index+1];
  
      float newScale = [imageScroll zoomScale] * 2.0;
  
      if (newScale &gt; imageScroll.maximumZoomScale){
          newScale = imageScroll.minimumZoomScale;
          CGRect zoomRect = [self zoomRectForScale:newScale withCenter:[gestureRecognizer locationInView:gestureRecognizer.view]];
  
          [imageScroll zoomToRect:zoomRect animated:YES];
  
      }
      else{
  
          newScale = imageScroll.maximumZoomScale;
          CGRect zoomRect = [self zoomRectForScale:newScale withCenter:[gestureRecognizer locationInView:gestureRecognizer.view]];
  
          [imageScroll zoomToRect:zoomRect animated:YES];
      }
  }
  
  #pragma mark Utility methods
  
  - (CGRect)zoomRectForScale:(float)scale withCenter:(CGPoint)center {
      CGRect zoomRect;
  
      // the zoom rect is in the content view's coordinates.
      //    At a zoom scale of 1.0, it would be the size of the imageScrollView's bounds.
      //    As the zoom scale decreases, so more content is visible, the size of the rect grows.
      zoomRect.size.height = [image_scroll frame].size.height / scale;
      zoomRect.size.width  = [image_scroll frame].size.width  / scale;
  
      // choose an origin so as to get the right center.
      zoomRect.origin.x    = center.x - (zoomRect.size.width  / 2.0);
      zoomRect.origin.y    = center.y - (zoomRect.size.height / 2.0);
  
      return zoomRect;
  }
  
  - (void)scrollViewDidScroll:(UIScrollView *)scrollView1
  {
      UIScrollView *imageScroll = (UIScrollView *)[self.view viewWithTag:self.selected_index+1];
      if(scrollView1.tag ==0){
          CGFloat pageWidth = scrollView1.frame.size.width;
          current_page = floor((scrollView1.contentOffset.x - pageWidth / 2.0) / pageWidth) + 1;
          self.selected_index=current_page;
          self.lblHeader.text=[NSString stringWithFormat:@"%ld of %lu",self.selected_index+1,(unsigned long)[self.PhotoImgArr count]];
  
      }
      else
      {
          CGFloat offsetX = (imageScroll.bounds.size.width &gt; imageScroll.contentSize.width)?
          (imageScroll.bounds.size.width - imageScroll.contentSize.width) * 0.5 : 0.0;
          CGFloat offsetY = (imageScroll.bounds.size.height &gt; imageScroll.contentSize.height)?
          (imageScroll.bounds.size.height - imageScroll.contentSize.height) * 0.5 : 0.0;
          [scrollView1.subviews objectAtIndex:0].center = CGPointMake(imageScroll.contentSize.width * 0.5 + offsetX,imageScroll.contentSize.height * 0.5 + offsetY);
      }
  
  }
  
  -(UIView *) viewForZoomingInScrollView:(UIScrollView *)scrollView1
  {
      if([scrollView1.subviews count]&gt;0){
          return [scrollView1.subviews objectAtIndex:0];
  
      }
      return nil;
  }
  </code></pre>