Reputation: 3965
I have a ViewController that contains a UIScrollView with an image. The user can zoom/pan the image using the UIScrollView. After the user is done, I need to crop the image. I can do the math to find the visible rectangle using the zoomScale and contentOffset... but it doesn't work the same in iOS6 vs iOS7. If I zoom to the almost exact same spot using both versions of the simulator, and NSLog the info, this is what i get:
iOS7:
zoom: 2.56
content offset: {256.5, 274}
content size: {817.75256, 817.75256}
picture size: {960, 960}
scrollview bounds: {{256.5, 274}, {320, 320}}
iOS6:
zoom: 2.54
content offset: {170.5, 182}
content size: {813.26, 813.26}
picture size: {960, 960}
scrollview bounds: {{170.5, 182}, {320, 320}}
The zoom and content sizes are slightly different, which is fine since I am manually attempting to zoom to the same spot on both simulators. But why the massive difference in contentOffset?
Simulators used:
Also, I am using self.automaticallyAdjustsScrollViewInsets = NO; for iOS7
Upvotes: 0
Views: 319
Reputation: 3965
I figured it out. Apparently, panning/zooming an image in a UIScrollView in iOS 6 WITH Autolayout is pretty tricky. Some workarounds need to be taken to get it working properly. The easiest thing for me was to create a separate storyboard file with Autolayout disabled, and move this view controller there. Works like a charm now.
Upvotes: 1