Skip to content

Commit

Permalink
* refactored iOS 4 code to work on 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dlinsin committed Jan 4, 2011
1 parent e3a7f6b commit 66f0890
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions OBSlider/OBSlider.m
Expand Up @@ -97,6 +97,16 @@ - (BOOL) beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event
return beginTracking;
}

- (NSUInteger) findIndexOfLowerScrubbingSpeed:(NSArray*)scrubbingSpeedPositions :(CGFloat)verticalOffset {
for (int i=0; i < [scrubbingSpeedPositions count]; i++) {
NSNumber *obj = [scrubbingSpeedPositions objectAtIndex:i];
if (verticalOffset < [obj floatValue]) {
return i;
}
}
return NSNotFound;
}


- (BOOL) continueTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event
{
Expand All @@ -108,9 +118,7 @@ - (BOOL) continueTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event

// Find the scrubbing speed that curresponds to the touch's vertical offset
CGFloat verticalOffset = fabsf(currentLocation.y - self.beganTrackingLocation.y);
NSUInteger scrubbingSpeedChangePosIndex = [self.scrubbingSpeedChangePositions indexOfObjectPassingTest:^(id obj, NSUInteger idx, BOOL *stop) {
return (BOOL)(verticalOffset < [obj floatValue]);
}];
NSUInteger scrubbingSpeedChangePosIndex = [self findIndexOfLowerScrubbingSpeed:self.scrubbingSpeedChangePositions :verticalOffset];
if (scrubbingSpeedChangePosIndex == NSNotFound) {
scrubbingSpeedChangePosIndex = [self.scrubbingSpeeds count];
}
Expand Down

0 comments on commit 66f0890

Please sign in to comment.