1
votes

Setup:

Tab Bar App

First View is a ScrollView which has an ImageView as its subview, loaded from a file.

All of the above configured in IB.

Application properly launches and I can scroll around the image and all is right with the world.

I have it scaling in and out with pinch controls no problem as well.

Now however I am trying to utilize setZoomScale to 1.0 when the user double taps... And it does indeed set the ZoomScale to 1.0..

The problem is however, that it moves the view to position 0,0 when it does it... completely ignoring the contentOffset values... Even when my next call after the setZoomScale is a call to set the contentOffset to soemthing else, nothing happens...

So, I'm a bit confused.. I'm not sure why the setZoomScale refocuses the view to 0,0 and worse yet, I don't understand why the view would not move to the contentOffset that the next line of code says it should even if it does reset it to 0,0.

Any ideas or suggestions? I know I could use zoomToRect, but I would really like to know what is going on here.

1

1 Answers

1
votes

Zoom To Rect does the same thing.. this is getting unbelievably frustrating... any programmatic change to the zoomScale in the UIScrollView just takes it to coordinate 0,0...

In Zoom To Rect, the rectangle being passed in is exactly what I want but it just zooms and goes to coordinates 0,0.. does anyone have any ideas on this? This makes no sense to me at all.

UPDATE:

Ok, I have figured out the culprit, but not the solution... the zoomToScale is triggering the contentMode of the subView, which in this case I have set to TOP LEFT... So every zoomToScale call or setZoomScale, etc.. is triggering the image to be redrawn on the screen at 0,0.

Now user interaction pinching and zooming and scrolling are not triggering this.

Now I just have to figure out a way to fix it.. I don't want the view to trigger the UIViewContentMode setting when I ask the scrollview to zoom, but I have no idea how to halt this.. changing the setting to redraw winds up with blank screen, and the other values are inappropriate as well, since I don't want the image moved.. I just want it zoomed.

Any ideas?