title: UIScrollView with an ImageView not scrolling vertically
body: <p>I have a <code>UIImageView</code> and it has an image larger than the screen size. I have this <code>UIImageView</code> as a sub view of <code>UIScrollView</code>. Now, I am unable to scroll down. to view the whole image. But the zooming functionalities are working fine.</p>
  
  <pre><code>@IBOutlet weak var scrollView: UIScrollView!
  
  var imageView = UIImageView();
  
  override func viewDidLoad() {
      super.viewDidLoad()
  }
  
  func centerScrollViewContents(){
      let boundsSize = scrollView.bounds.size
      var contentsFrame = imageView.frame
  
      if contentsFrame.size.width &lt; boundsSize.width {
         contentsFrame.origin.x = (boundsSize.width - contentsFrame.size.width) / 2
      }
      else { 
         contentsFrame.origin.x = 0
      }
  
      if contentsFrame.size.height &lt; boundsSize.height {            
          contentsFrame.origin.y = (boundsSize.height - contentsFrame.size.height) / 2
      }
      else {
          contentsFrame.origin.y = 0
      }
  
      imageView.frame = contentsFrame
     // scrollView.frame = contentsFrame        
  }
  
  func scrollViewDidZoom(scrollView: UIScrollView) {
      centerScrollViewContents()
  }
  
  func viewForZoomingInScrollView(scrollView: UIScrollView) -&gt; UIView? {
      return imageView
  }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
  
      // Dispose of any resources that can be recreated.
  }
  
  override func viewDidAppear(animated: Bool) {
  
      scrollView.delegate = self
      imageView.frame = CGRectMake(0, 0, scrollView.frame.size.width, scrollView.frame.size.height)
  
     // imageView.contentMode = UIViewContentMode.ScaleAspectFill
     // imageView.clipsToBounds = true
      imageView.image = UIImage(named: imgstr)
  
      var imagee = UIImage(named: imgstr)
      let size = imagee?.size
     // imageView.frame = CGRectMake(0, 0, size.width!, size.height!)
      imageView.contentMode = .Top
      scrollView.addSubview(imageView)
  
      scrollView.contentSize = size!
      let scrollViewFrame = scrollView.frame
      let scaleWidth = scrollViewFrame.size.width / scrollView.contentSize.width
      let scaleHeight = scrollViewFrame.size.height / scrollView.contentSize.height
      let minScale = min(scaleHeight, scaleWidth)
  
      scrollView.minimumZoomScale = 1
      scrollView.maximumZoomScale = 5
      scrollView.zoomScale = minScale
  
      centerScrollViewContents()   
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/xTc4M.png" alt="enter image description here"></p>