Tuesday, 15 April 2014

uiscrollview - UIPanGestureRecognizer translationInView returning different values on iPhone/ipad -



uiscrollview - UIPanGestureRecognizer translationInView returning different values on iPhone/ipad -

hi have bit of code in project,

- (void)scrollviewwillbegindragging:(uiscrollview *)scrollview { cgpoint translation = [scrollview.pangesturerecognizer translationinview:scrollview]; if(translation.x < 0.0f) { // } }

and works fine on iphone, reason on ipad, cgpoint returning (0,0). ideas why?

had same problem, , came nasty workaround, using velocityinview() method instead. don't have real ipad, i'm suspicious problem may simulator.

objective-c:

class="lang-swift prettyprint-override">cgpoint velocity = [scrollview.pangesturerecognizer velocityinview: scrollview]; cgpoint translation = cgpointmake(velocity.x * 0.1, velocity.y * 0.1);

swift:

class="lang-swift prettyprint-override">let translation = scrollview.pangesturerecognizer.velocityinview(self) * 0.1

i'm using handy cgpoint extension can find right here.

uiscrollview uipangesturerecognizer

No comments:

Post a Comment