0
votes

I'd like to make a very simple crop tool. I have UIImage in UIScrollview with UIImage set to Aspect Fill.

The problem is:

  • When I load an image that is bigger than the UIIMageview, it fills nicely but I can't pan around it.

  • When a zoom in a little bit, I am somewhat able to pan around but I can't pan to the very edge, it always bounces back.

The UIScrollView and UIImageView have same size, UIImageView is hooked to the UIScrollView via AutoLayout and the UIScrollView is hooked to the UIView with AutoLayout aswell.

I instantiated the scrollview like this:

@IBOutlet weak var scrollView: UIScrollView!{
    didSet{
        scrollView.delegate = self
        
        scrollView.showsVerticalScrollIndicator = false
        scrollView.showsHorizontalScrollIndicator = false
        scrollView.minimumZoomScale = 1.0
        scrollView.maximumZoomScale = 10.0
    }
}

Alt Text

1

1 Answers

0
votes

I'd say your main issue here is that when you zoom in, the scrollView's contentSize is not adapting to the new dimension of the UIImage. That bouncing back is usually when you try to scroll beyond the limits of the contentSize. Look over how you set the contentSize of the UIScrollView when zooming. I bet that you might have overlooked or omitted something there.