ios - Swift UIScrollView setZoomScale Zooming To Wrong Point -
i have zoomable uiimageview
within uiscrollview
. if user double taps on image, uiscrollview
zoom in until image fills screen. have zoom scale set in code. part of code works great. here code:
func scrollviewdoubletapped(tapgesture: uitapgesturerecognizer) { // zoom zoom scale if @ min zoom, else zoom min zoom if (scrollview.zoomscale == scrollview.minimumzoomscale) { scrollview.setzoomscale(zoomscale, animated: true) } else { scrollview.setzoomscale(scrollview.minimumzoomscale, animated: true) } }
the problem comes if want zoom specified zoom scale right when view loaded. when attempt zooming, offset incorrect. have println
within function scrollviewdidendzooming
show me offset, scale, , anchor point.
func scrollviewdidendzooming(scrollview: uiscrollview, withview view: uiview!, atscale scale: cgfloat) { println("did end zooming scale: \(scale)") println("offset: \(scrollview.contentoffset)") println("anchor point: \(scrollview.layer.anchorpoint)") }
when attempt zoom after view loaded, values:
did end zooming scale: 2.27556 offset: (490.0, -0.0) anchor point: (0.5, 0.5)
which has incorrect y offset. when double tap on image zoom in get:
did end zooming scale: 2.27556 offset: (490.0, 653.0) anchor point: (0.5, 0.5)
would able me figure out why i'm having issues zooming when view loaded. call viewdidappear
function.
Comments
Post a Comment