0

I have looked into all these SO answers but none of them seem to address the issue I'm facing.

The short of it is that my scroll/zooming code works as I expect it to on pre retina devices, but on 4, 4S & 5 with iOS 5.x & 6.x my code works for any value of the zoom below 1.0 I tested it with, but breaks when zoomScale is precisely 1.0 or above.

At that point the whole view is shifted towards the top/left

This code:

- (void) layoutSubviews {

    [super layoutSubviews] ;

    ::NSLog(@"x:%.02f contentOffset (%0.2f:%0.2f)"
    ,   self.zoomScale
    ,   self.contentOffset.x
    ,   self.contentOffset.y) ;
}

produces this on retina: (jerky transition for zoomScale from less than 1.0 to greater than 1.0)

x:0.96 contentOffset (1334.37:622.55)
x:0.98 contentOffset (1371.34:639.45)
x:1.00 contentOffset (226.45:202.26) 
x:1.02 contentOffset (227.59:204.19) 
x:1.03 contentOffset (228.71:206.10) 

produces this on NON retina: (smooth transition for zoomScale from less than 1.0 to greater than 1.0)

x:0.95 contentOffset (2211.01:2247.41) 
x:0.97 contentOffset (2257.25:2295.54) 
x:0.99 contentOffset (2303.52:2343.69) 
x:1.03 contentOffset (2403.40:2447.63) 
x:1.05 contentOffset (2457.57:2504.00) 

Anyone?

EDIT Logging the scrolled/zoomed view transform produces consistent (and still wrong!) results:

Non Retina

scale:0.98 contentOffset(29.11:40.02) transform: [0.978491, 0, 0, 0.978491, 0, 0]
scale:0.99 contentOffset(31.79:43.71) transform: [0.992378, 0, 0, 0.992378, 0, 0]
scale:1.01 contentOffset(35.71:49.11) transform: [1.01268, 0, 0, 1.01268, 0, 0]
scale:1.03 contentOffset(38.40:52.79) transform: [1.02656, 0, 0, 1.02656, 0, 0]
scale:1.04 contentOffset(41.09:56.49) transform: [1.04048, 0, 0, 1.04048, 0, 0]

Retina

scale:0.98 contentOffset(1377.56:1511.69) transform: [0.984364, 0, 0, 0.984364, 0, 0]
scale:0.99 contentOffset(1392.50:1528.51) transform: [0.993929, 0, 0, 0.993929, 0, 0]
scale:1.02 contentOffset(227.42:300.11) transform: [1.01742, 0, 0, 1.01742, 0, 0]
scale:1.03 contentOffset(228.26:301.48) transform: [1.02922, 0, 0, 1.02922, 0, 0]
scale:1.03 contentOffset(228.48:301.84) transform: [1.03236, 0, 0, 1.03236, 0, 0]
Community
  • 1
  • 1
verec
  • 5,224
  • 5
  • 33
  • 40

1 Answers1

0

Fixed.

When I replaced in the initialization

 self.scrollView.contentSize = (CGSize) {CGFLOAT_MAX, CGFLOAT_MAX} ;

with

self.scrollView.contentSize = (CGSize) {1e9, 1e9} ;

Then the zoomScale and contentOffset become consistant across retina and non retina device.

My guess is that when Apple introduced the retina devices, they also (inadvertently?) reduced the span of the floating point coordinate space from

[CGFLOAT_MIN, CGFLOAT_MAX]

to

[undefined, CGFLOAT_MAX/retina-device-scale]

...

verec
  • 5,224
  • 5
  • 33
  • 40