Created
January 1, 2013 17:18
-
-
Save anonymous/4428748 to your computer and use it in GitHub Desktop.
Find the leaks (AKA as - the reason I shot myself in the head)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)swipeDetected:(UIPanGestureRecognizer *)sender | |
{ | |
CGPoint p = [sender translationInView:self]; | |
CGFloat currentPointY; | |
CGFloat velocityX = [sender velocityInView:self.superview].x; | |
p.x += velocityX / SWIPE_THRESHOLD * 10; | |
if (sender.state == UIGestureRecognizerStateBegan) { | |
CGFloat currentPointY = p.y; | |
if (p.x >= 0) { | |
[self createStatusSwipeBackgroundViewForStatus:@"BUY"]; | |
} else { | |
[self createStatusSwipeBackgroundViewForStatus:@"SELL"]; | |
} | |
} else if (sender.state == UIGestureRecognizerStateChanged) { | |
if (ABS(p.y - currentPointY) > SWIPE_Y_AXIS_THRESHOLD) { | |
[self handleStopSwipeWithXAxis:p.x]; | |
return; | |
} | |
if (p.x > 0) { | |
[self handleSwipeXAxisChangedFromLeftToRightWithXAxis:p.x]; | |
} else { | |
[self handleSwipeXAxisChangedFromRightToLeftWithXAxis:p.x]; | |
} | |
} else if (sender.state == UIGestureRecognizerStateEnded || | |
sender.state == UIGestureRecognizerStateFailed || | |
sender.state == UIGestureRecognizerStateCancelled) { | |
[self setStatusActionLinesHidden:NO]; | |
if ([self isActionForSameStatusWithXAxis:p.x]) return; | |
if (p.x > SWIPE_THRESHOLD) { | |
[self.delegate cellBuyWithSender:self]; | |
} | |
if (-1 * p.x > SWIPE_THRESHOLD) { | |
[self.delegate cellSellWithSender:self]; | |
} | |
[UIView animateWithDuration:0.4 animations:^{ | |
self.origin = CGPointMake(0, self.origin.y); | |
if (p.x > 0) { | |
self.swipeBackgroundImage.origin = CGPointMake(-self.swipeBackgroundImage.width, self.swipeBackgroundImage.origin.y); | |
} else{ | |
self.swipeBackgroundImage.origin = CGPointMake(self.width, self.swipeBackgroundImage.origin.y); | |
} | |
} completion:^(BOOL finished) { | |
}]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
is it that you redefined currentPointY in the first if, using a new currentPointY instead of the one in the function scope? Or that you didn't use static on the first currentPointY so when reentering the function currentPointY when sender.state == UIGestureRecognizerStateChanged is undefined?