Question

I am doing something that seems like it should be really simple, but I am seeing strange results that I have not been able to understand.

I have a UIImageView inside of (and the size of) a UIScrollView, which is the size of the iOS device it is running on. All of this is defined in IB.

I have the delegate method define for

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

While zooming, I see the following delegate methods called:

viewForZoomingInScrollView
viewForZoomingInScrollView
viewForZoomingInScrollView
scrollViewWillBeginZooming
scrollViewDidZoom
scrollViewDidScroll scrollView contentOffset: NSPoint: {23.675083, 18.840801}
scrollViewDidZoom
scrollViewDidScroll scrollView contentOffset: NSPoint: {44.748684, 35.630745}
… REPEATED MANY TIMES...
scrollViewDidZoom
scrollViewDidScroll scrollView contentOffset: NSPoint: {782.82373, 588.79358}
scrollViewDidZoom
scrollViewDidScroll scrollView contentOffset: NSPoint: {791.22223, 594.99152}
scrollViewDidZoom
scrollViewDidScroll scrollView contentOffset: NSPoint: {791, 595}
scrollViewDidEndZooming scale factor: 2.498063
scrollViewDidEndZooming scrollView frame: NSRect: {{0, 0}, {768, 1024}}
scrollViewDidEndZooming scrollView bounds: NSRect: {{791, 595}, {1024, 768}}
scrollViewDidEndZooming view frame: NSRect: {{0, 0}, {2558.0161, 1918.5121}}
scrollViewDidEndZooming view bounds: NSRect: {{0, 0}, {1024, 768}}
scrollViewDidEndZooming scrollView contentOffset: NSPoint: {791, 595}
scrollViewDidScroll scrollView contentOffset: NSPoint: {-0, -0}
RE-WORK IMAGE AND DRAW NOW

What is confusing and causes the image to shift is that last scrollViewDidScroll with the contentOffset reset to {0,0}. It seems like I must have inadvertently left a property set or unset that results in this behavior, but I have not found what it is yet.

Any hints of suggests will be greatly appreciated.

Was it helpful?

Solution

The solution is to disable Autolayout.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top