Skip to content
This repository has been archived by the owner on Dec 2, 2020. It is now read-only.

Commit

Permalink
Touch Report number of fingers required
Browse files Browse the repository at this point in the history
Adds a feature to specify the number of fingers required to report
touches to the delegate.
  • Loading branch information
Sam Spencer committed Jan 24, 2016
1 parent 94f8915 commit 30472dc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions Classes/BEMSimpleLineGraphView.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ IB_DESIGNABLE @interface BEMSimpleLineGraphView : UIView <UIGestureRecognizerDel
@property (nonatomic) BOOL enableTouchReport;


/** The number of fingers required to report touches to the graph's delegate. The default value is 1.
@discussion Setting this value to greater than 1 might be beneficial in interfaces that allow the graph to scroll and still want to use touch reporting. */
@property (nonatomic) NSInteger touchReportFingersRequired;


/// If set to YES, a label will pop up on the graph when the user touches it. It will be displayed on top of the closest point from the user current touch location. Default value is NO.
@property (nonatomic) BOOL enablePopUpReport;

Expand Down
9 changes: 5 additions & 4 deletions Classes/BEMSimpleLineGraphView.m
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ - (void)commonInit {

// Set Default Feature Values
_enableTouchReport = NO;
_touchReportFingersRequired = 1;
_enablePopUpReport = NO;
_enableBezierCurve = NO;
_enableXAxisLabel = YES;
Expand Down Expand Up @@ -1293,22 +1294,22 @@ - (void)setAnimationGraphStyle:(BEMLineAnimation)animationGraphStyle {

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
if ([gestureRecognizer isEqual:self.panGesture]) {
if (gestureRecognizer.numberOfTouches > 0) {
if (gestureRecognizer.numberOfTouches >= self.touchReportFingersRequired) {
CGPoint translation = [self.panGesture velocityInView:self.panView];
return fabs(translation.y) < fabs(translation.x);
} else return NO;
return YES;
} else return NO;
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return YES;
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
return YES;
}


- (void)handleGestureAction:(UIGestureRecognizer *)recognizer {
CGPoint translation = [recognizer locationInView:self.viewForBaselineLayout];

Expand Down

0 comments on commit 30472dc

Please sign in to comment.