0
votes

I've got some problem when i'm zooming, when i zoom the next UIImageView goes above the UIImageView i m zooming in.

I load my UIImageView in a subclass of a UIScrollView that i call in controller. The load function and Scroll function work perfectly.

The first problem is that when I zoom in the next UIImageView goes above the one that i m zooming in.

So i tried to put every UIImageView in a UIView that i put into the ScrollView but it does the same things...

The 2nd problem that I have is that when i zoom in, my scroll doesn't work anymore.

- (UIView*)viewForZoomingInScrollView:(UIScrollView *)scrollView {
// Return the view that you want to zoom
NSLog(@"viewForZoomingInScrollView - current : %d",self.scrollPageControl.currentPage);
return [[[[self.productImageScrollView subviews]objectAtIndex:0] subviews]objectAtIndex:self.scrollPageControl.currentPage];
//return [[self.productImageScrollView subviews] objectAtIndex:0];
//return [self.productImageScrollView getSubViewsByPage:[NSNumber numberWithInteger:[self.scrollPageControl currentPage]]];

The first return return a UIImageView of the UIView The second return the UIView the third return the UIImageView when i don't use the UIView.

I saw a lot of similar problem but nothing i tried helped me ... So I m calling you ! Ty ask me if i'm not clear.

3

3 Answers

0
votes

try creating an UIView * (maybe call it contentView) and put all of your UIImageView's as subviews to that contentView

then, on the

- (UIView*)viewForZoomingInScrollView:(UIScrollView *)scrollView {
    return contentView;
}
0
votes

Are you returning that view in the method? that's the key part ...

The scroll view will only scale the view you return in the viewForZooming, so if you are returning one of your images, the rest will not scale. I assume you are adding them in order, so when the zoomed one enlarges, the next one will stay still and therefore be on top of the current one

Try adding all the images to a view and then return that same view in the viewForZoomingInScrollView:

0
votes

This is the function that determine what object will zoom:

func viewForZooming(in scrollView: UIScrollView) -> UIView?{
    return scrollImageView
}

then you can add what you want to that object as a subview and it will zoom to:

scrollImageView.addSubview(teritorysImages)