title: iOS: UIScrollView zooming programmatically not working
body: <p>I have a pageable UIScrollView which contains different kind of informations like UITables but also zoomable images. Therefore I set up a pageable main-ScrollView and as subviews I added zoomable image-ScrollViews with the images as content.
  Works everything fine, just I fail to set the smaller current zoom scale of the imageScrollViews.</p>
  
  <pre><code>UIImageView *imageView = [[UIImageView alloc] initWithImage:Image];
  
  //storing a link to the imageView
  [imagelinkArray addObject:imageView];
  
  CGRect ScrollViewImageRect;
  ScrollViewImageRect = CGRectMake((self.scrollView.frame.size.width) * i, 0, 320, self.scrollView.frame.size.height);
  
  float widthfactor = ScrollViewImageRect.size.width / imageView.frame.size.width;
  float heightfactor = ScrollViewImageRect.size.height / imageView.frame.size.height;
  float zoomscale = MIN(widthfactor, heightfactor);
  
  UIScrollView *imageScrollView = [[UIScrollView alloc] initWithFrame:ScrollViewImageRect];
  imageScrollView.contentSize = CGSizeMake(imageView.frame.size.width, imageView.frame.size.height);
  
  imageScrollView.delegate = self;
  
  [imageScrollView setMinimumZoomScale:zoomscale];
  [imageScrollView setMaximumZoomScale:1.5];
  
  [imageScrollView addSubview:imageView];
  
  //doesn't work:
  [imageScrollView setZoomScale:0.5 animated:YES];
  
  [self.scrollView addSubview:imageScrollView];
  
  - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
  {
      return [imagelinkArray objectAtIndex:page];
  }
  </code></pre>
  
  <p>The main-ScrollView and the image-ScrollViews are drawn perfectly and it's possible to zoom and page properly. The minimum zoom factor is calculated also correct. When I zoom out I can zoom until the image limits are reached. However the first time I page to the image-ScrollView it's current zoom scale is always 1.0 while it should be the minimum scale.</p>
  
  <p>Wherever I set the zoom scale in the code above it doesn't work: </p>
  
  <pre><code>[changeScrollView setZoomScale:changeScrollView.minimumZoomScale animated:YES];
  </code></pre>
  
  <p>If I log the current zoom scale i always get 1.0;</p>
  
  <p>The only thing which works is changing the zoom scale in the <code>- (void)scrollViewDidScroll:</code> method, which of course doesn't help a lot since zooming also calls it which resets the zoom immediately. But at least I could figure out, that the code somehow works. I have the feeling a UIScrollView doesn't zoom when it's not visible on the screen right now. How can I fix this?</p>
  
  <p><strong>Update:</strong>
  Okay. In the meantime I figured out that the problem most likely comes from my base layout of "sub-viewing" ScrollViews into another ScrollView. When I zoom one of the images and log the current zoom factor of the ScrollViews they are all the same (main ScrollView as well as ALL sub-ScrollViews).
  What could be the reason for it or how could I solve it with a different layout?</p>