Iphone – Updating zoomScale of UIScrollView

iphone

I just created an animation to zoom in or zoom out a UIScrollView, but my problem is that the zoomScale is not updating. Like for example, I zoom out my UIView inside of my UIScrollView using the animation I created, but when I zoom in using expand gesture the UIView will automatically change to its big size or zoom in size. I saw the my zoomScale is not updating and still in 1.0 scale. Then I update my zoomScale after the animation but the problem is the zoom out UIView will automatically go to the top of the screen. Can I update this zoomScale property of UIScrollView?

Thanks.

Best Answer

Did you implement viewForZoomingInScrollView function ? This function of your scroll view delegate is called when you change the zoomScale. It returns the view that must be rescaled when the scale of your scrollview is changed. In general you just return the scrollView given in parameters :

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView; {
    return scrollView.childView;
}

Don't forget to set a delegate to your scrollview : yourScrollView.delegate = self;

Related Topic