Solved the problem. The touchesMoved:withEvent: should be implemented this way:
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches.allObjects objectAtIndex:0];
CGPoint location = [touch locationInView:self];
CGPoint previousLocation = [touch previousLocationInView:self];
CGPoint contentOffset = self.contentOffset;
contentOffset.x -= location.x - previousLocation.x;
[self setContentOffset:contentOffset animated:NO];
}