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

Commit 30472dc

Browse files
author
Sam Spencer
committed
Touch Report number of fingers required
Adds a feature to specify the number of fingers required to report touches to the delegate.
1 parent 94f8915 commit 30472dc

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

Classes/BEMSimpleLineGraphView.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ IB_DESIGNABLE @interface BEMSimpleLineGraphView : UIView <UIGestureRecognizerDel
155155
@property (nonatomic) BOOL enableTouchReport;
156156

157157

158+
/** The number of fingers required to report touches to the graph's delegate. The default value is 1.
159+
@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. */
160+
@property (nonatomic) NSInteger touchReportFingersRequired;
161+
162+
158163
/// 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.
159164
@property (nonatomic) BOOL enablePopUpReport;
160165

Classes/BEMSimpleLineGraphView.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ - (void)commonInit {
174174

175175
// Set Default Feature Values
176176
_enableTouchReport = NO;
177+
_touchReportFingersRequired = 1;
177178
_enablePopUpReport = NO;
178179
_enableBezierCurve = NO;
179180
_enableXAxisLabel = YES;
@@ -1293,22 +1294,22 @@ - (void)setAnimationGraphStyle:(BEMLineAnimation)animationGraphStyle {
12931294

12941295
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
12951296
if ([gestureRecognizer isEqual:self.panGesture]) {
1296-
if (gestureRecognizer.numberOfTouches > 0) {
1297+
if (gestureRecognizer.numberOfTouches >= self.touchReportFingersRequired) {
12971298
CGPoint translation = [self.panGesture velocityInView:self.panView];
12981299
return fabs(translation.y) < fabs(translation.x);
12991300
} else return NO;
13001301
return YES;
13011302
} else return NO;
13021303
}
13031304

1304-
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{
1305+
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
13051306
return YES;
13061307
}
1307-
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
1308+
1309+
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
13081310
return YES;
13091311
}
13101312

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

0 commit comments

Comments
 (0)