Hi i'm trying to forward the touches I receive from an UIView which is in front of an UITableView. But doins so I can't make the table scroll anymore (see here).
So now I'm trying to make tha tableview scroll programmatically and I am looking at setContentOffset:animated:
and scrollRectToVisible:animated:
with having success only with the first.
Here is my code in a class that subclasses the UITableView:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"BEGTB");
//previousXPan = 0.0;
UITouch * touch = [touches anyObject];
CGPoint tPoint = [touch locationInView:self];
previousYPan = tPoint.y;
[super touchesBegan:touches withEvent:event];
//
//[super touchesShouldBegin:touches withEvent:event inContentView:self];
//[[self nextResponder] touchesBegan:touches withEvent:event];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch * touch = [touches anyObject];
CGPoint tPoint = [touch locationInView:self];
NSLog(@"MOVTB");
NSLog(@"BOUNDZ %f, %f, %f, %f", self.bounds.origin.x, self.bounds.origin.y, self.bounds.size.height, self.bounds.size.width);
NSLog(@"CONTENT SIZE %f, %f", self.contentSize.height, self.contentSize.width);
CGRect rc = [self bounds];
NSLog(@"%f %f", rc.size.height, rc.size.width);
CGRect newRect = CGRectMake(rc.origin.x, rc.origin.y + self.contentSize.height, self.contentSize.width, fabs(tPoint.y - previousYPan));
NSLog(@"BOND RECT %f, %f, %f, %f", rc.origin.x, rc.origin.y, rc.size.height, rc.size.width);
NSLog(@"NEW RECT %f, %f, %f, %f", newRect.origin.x, newRect.origin.y, newRect.size.height, newRect.size.width);
//[self scrollRectToVisible:newRect animated:YES];
NSLog(@"Content OFFSET %f",tPoint.y - previousYPan);
[self setContentOffset:CGPointMake(rc.origin.x,(tPoint.y - previousYPan) *2.0 )animated:YES];
previousYPan = tPoint.y;
//[super touchesMoved:touches withEvent:event];
//[[self nextResponder] touchesMoved:touches withEvent:event];
}
But the result is really laggy and buggy. Any better idea?