title: UIScrollView with centered UIImageView, like Photos app
body: <p>I would like to have scroll view with an image content view. The image is actually map which is much bigger than the screen. The map should be initially in the center of the scroll view, like photos in Photos app when you turn iPhone to landscape orientation.</p>
  
  <p><img src="https://lh4.ggpht.com/_bowYsy0VxgU/Sbj0Vjz5twI/AAAAAAAAAy0/CHM6LRsNkTo/scrollView.png" alt="alt text"></p>
  
  <p>I did not manage to have the map in the center with correct zooming and scrolling at the same time.
  Provided that the map image starts from the top of the screen (in portrait orientation), the code looks something like:</p>
  
  <pre><code>- (void)loadView {
      mapView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"map.jpg"]];
      CGFloat mapHeight = MAP_HEIGHT * SCREEN_WIDTH / MAP_WIDTH;
      mapView.frame = CGRectMake(0, 0, SCREEN_WIDTH, mapHeight);
      scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
      scrollView.delegate = self;
      scrollView.contentSize = mapView.frame.size;
      scrollView.maximumZoomScale = MAP_WIDTH / SCREEN_WIDTH;
      scrollView.minimumZoomScale = 1;
      [scrollView addSubview:mapView];
      self.view = scrollView;
  }
  </code></pre>
  
  <p>When I move the image frame to the center, the image grows only from the top of its frame down. I tried to play around with mapView transform, with dynamically changing frame of the imageView. Nothing works for me so far.</p>