title: scrollViewDidEndZooming not called while zooming in a UIScrollView
body: <p>This could possibly be an Xcode bug? I have an <code>UIImage</code> inside a <code>UIScrollView</code> done programatically in code. The user can zoom into the image using the zoom gesture or double tapping the image. This part all works fine.</p>
  
  <p>Next, I am trying to detect when the scroll view has finished zooming after a zoom gesture or double tap using the below function <code>scrollViewDidEndZooming</code>. However, <code>scrollViewDidEndZooming</code> never gets called, and doesn't print the line <code>I just finished zooming!</code></p>
  
  <p><strong>Code not working:</strong></p>
  
  <pre><code>func scrollViewDidEndZooming(scrollView: UIScrollView, with view: UIView?, atScale scale: CGFloat) {
      print("I just finished zooming!")
  }
  </code></pre>
  
  <blockquote>
    <p><strong>Question:</strong></p>
    
    <p>What might be going on here, why isn't <code>scrollViewDidEndZooming(...)</code>
    getting called?</p>
  </blockquote>
  
  <p>Note: I've referred to the below document with no luck.
  <a href="https://developer.apple.com/reference/uikit/uiscrollviewdelegate/1619407-scrollviewdidendzooming" rel="nofollow">https://developer.apple.com/reference/uikit/uiscrollviewdelegate/1619407-scrollviewdidendzooming</a></p>
  
  <hr>
  
  <p><strong>Complete code:</strong></p>
  
  <pre><code>class ScrollViewController: UIViewController, UIScrollViewDelegate {
      var scrollView: UIScrollView!
      var imageView: UIImageView!
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          imageView = UIImageView(image: UIImage(named: "image.png"))
  
          scrollView = UIScrollView(frame: view.bounds)
          scrollView.backgroundColor = UIColor.blackColor()
          scrollView.contentSize = imageView.bounds.size
          scrollView.autoresizingMask = [UIViewAutoresizing.FlexibleWidth, UIViewAutoresizing.FlexibleHeight]
  
          scrollView.contentOffset = CGPoint(x: 1000, y: 450)
  
          scrollView.addSubview(imageView)
          view.addSubview(scrollView)
  
          scrollView.delegate = self
          setZoomScale()
          setupGestureRecognizer()
      }
  
      func viewForZoomingInScrollView(scrollView: UIScrollView) -&gt; UIView? {
          return imageView
      }
  
      override func viewWillLayoutSubviews() {
          setZoomScale()
      }
  
      func setZoomScale() {
          let imageViewSize = imageView.bounds.size
          let scrollViewSize = scrollView.bounds.size
          let widthScale = scrollViewSize.width / imageViewSize.width
          let heightScale = scrollViewSize.height / imageViewSize.height
  
          scrollView.minimumZoomScale = min(widthScale, heightScale)
          scrollView.zoomScale = 1.0
      }
  
      func scrollViewDidZoom(scrollView: UIScrollView) {
          let imageViewSize = imageView.frame.size
          let scrollViewSize = scrollView.bounds.size
          let verticalPadding = imageViewSize.height &lt; scrollViewSize.height ? (scrollViewSize.height - imageViewSize.height) / 2 : 0
          let horizontalPadding = imageViewSize.width &lt; scrollViewSize.width ? (scrollViewSize.width - imageViewSize.width) / 2 : 0
  
          scrollView.contentInset = UIEdgeInsets(top: verticalPadding, left: horizontalPadding, bottom: verticalPadding, right: horizontalPadding)
      }
  
      func scrollViewDidEndZooming(scrollView: UIScrollView, with view: UIView?, atScale scale: CGFloat) {
          print("I just finished zooming!")
      }
  
      func setupGestureRecognizer() {
          let doubleTap = UITapGestureRecognizer(target: self, action: "handleDoubleTap:")
          doubleTap.numberOfTapsRequired = 2
          scrollView.addGestureRecognizer(doubleTap)
      }
  
      func handleDoubleTap(recognizer: UITapGestureRecognizer) {
          if (scrollView.zoomScale &gt; scrollView.minimumZoomScale) {
              scrollView.setZoomScale(scrollView.minimumZoomScale, animated: true)
          } else {
              scrollView.setZoomScale(scrollView.maximumZoomScale, animated: true)
          }
      }
  }
  </code></pre>