             minScale = maxScale
         }
         
-        maximumZoomScale = maxScale
+        maximumZoomScale = 10   // TODO
         minimumZoomScale = minScale
-        print("min scale = \(minScale), max scale = \(maxScale)")
+        print("min scale = \(minimumZoomScale), max scale = \(maximumZoomScale)")
     }
     
     // MARK: - Rotation support

    }
    
    private var imageRotation = CGFloat(0)
    
    func setImageRotation(angle: CGFloat) {
        
        let radians = angle * CGFloat(M_PI) / 180
        let scale = scaleToFillBoundsWithImageRotatedBy(Double(radians))
        
        var transform = CGAffineTransformIdentity
        transform = CGAffineTransformScale(transform, scale, scale)
        transform = CGAffineTransformRotate(transform, radians)
        
        imageView.imageTransform = transform
        imageRotation = radians
        
        let corners = bounds.cornersByApplyingTransform(transform)
        debugPrint("bounds = \(bounds), corners = \(corners)")
    }
    
    // MARK: - UIScrollViewDelegate

    private func scaleToFillBoundsWithImageRotatedBy(angle: Double) -> CGFloat {
        
        let pi = M_PI
        let containerSize = bounds.size
        
        var theta = fabs(angle - 2 * pi * trunc(angle / pi / 2) - pi)
        if theta > pi / 2 {
            theta = fabs(pi - theta)
        }
        
        let H = Double(containerSize.height)
        let W = Double(containerSize.width)
        let h = Double(contentSize.height)
        let w = Double(contentSize.width)
        
        let scale1 = (H * cos(theta) + W * sin(theta)) / h
        let scale2 = (H * sin(theta) + W * cos(theta)) / w
