0
votes

Theres a wide UIScrollView (let's call it wideScroll) and inside it, smaller UIScrollViews (call them singleScrollViews). And there is a UIView in each SingleScrollView, which contains two different UIImageViews.

I need to use the scrolling delegates for the wideScroll, and zooming delegates for the singleScrollViews.

How I do this is, I use UIScrollView delegates in wideScroll class, and when a zooming event happens, I return the pointer of the desired singleScrollView's UIView in the method;

-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
    //here i determine "int someint" according to current page.
    SingleScrollView *b = (SingleScrollView *)[wideScrollView viewWithTag:someint];
    return ((UIView *)[b viewWithTag:WRAPPERVIEW_TAG]);
}

When I do this, the zooming of individual singleScrollViews work fine except one thing, which is, when singleScrollView reaches its maximumZoomScale, the zooming ends, but before "scrollViewDidEndZooming" method is called, "scrollViewDidZoom" is called one last time and set the content offset of UIView to (0,0), making the image scroll to top left.

On the contrary, when I zoom in without reaching maximumZoomScale, the UIView stays where it is zoomed, not scrolling to top or anything else.

Also, the "-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView" method is called thrice when I reach maximumZoomScale while zooming.

Any Ideas?

Workaround: I set the maximumzoomscale to 2.01 and when singleScrollView.ZoomScale is > 2.00, i set it back to 2.00 in the beginning of the ScrollViewDidZoom delegeta method.

1

1 Answers

0
votes

Take a look at the photoscroller sample example. And you need to implement viewForZooming individually for each single scrollview. That's the better approach of implementation.And override layoutSubview method and set the centre of your imageview in it based on your scrollview zoom scale