Flip scroll view with zoomed image in iPhone

482 views Asked by At

I am having 2 scrollviews which have imageviews inside it,

Following is the hierarchy, View -- ScrollView -- UIImageView -- Image

I have added pinch to zoom functionality, so that the user can zoom in,zoom out the image.

Now, while flipping the scrollview, if the image has been zoomed and i flip the view to backscrollview, i want the image to be reset to its original position.

How do I do that?

1

There are 1 answers

8
valfer On BEST ANSWER

You could use the UIScrollView delegate method:scrollViewWillBeginDragging. This tells you when a scrolling is going to begin. At this point you can reset the zoom and the position:

func scrollViewWillBeginDragging(scrollView: UIScrollView) {
   scrollView.zoomScale = 1
   scrollView.contentOffset = CGPoint(x: 0, y: 0)
}

(swift code but similar in objc)