Skip to content

Commit 370b1a6

Browse files
authored
change hitView to return touches to self.view if tap to close is set to true (#425)
1 parent 280334d commit 370b1a6

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

Leanplum-SDK/Classes/MessageTemplates/ViewControllers/LPWebInterstitialViewController.m

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,20 @@ - (void)viewDidLoad
6565
[self.dismissButton setHidden:YES];
6666
}
6767

68-
// passthrough view to send touch events to underlaying ViewController
69-
LPHitView* passthroughView = (LPHitView *) self.view;
70-
if (passthroughView) {
71-
passthroughView.touchDelegate = self.presentingViewController.view;
72-
}
73-
7468
// add gesture recognizer to close message if tap outside to close is set to true.
7569
BOOL tapOutside = [self.context boolNamed:LPMT_ARG_HTML_TAP_OUTSIDE_TO_CLOSE];
7670
if (tapOutside) {
7771
UITapGestureRecognizer* gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapOutside)];
7872
[self.view addGestureRecognizer:gestureRecognizer];
7973
}
8074

75+
// passthrough view to send touch events to underlaying ViewController
76+
LPHitView* passthroughView = (LPHitView *) self.view;
77+
if (passthroughView) {
78+
passthroughView.shouldAllowTapToClose = tapOutside;
79+
passthroughView.touchDelegate = self.presentingViewController.view;
80+
}
81+
8182
_orientation = UIDevice.currentDevice.orientation;
8283
[[NSNotificationCenter defaultCenter] addObserver:self
8384
selector:@selector(orientationDidChange:)

Leanplum-SDK/Classes/MessageTemplates/Views/LPHitView.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
@interface LPHitView : UIView
1212

1313
@property (weak, nonatomic) UIView *touchDelegate;
14+
@property (assign) BOOL shouldAllowTapToClose;
1415

1516
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event;
1617

Leanplum-SDK/Classes/MessageTemplates/Views/LPHitView.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
1818
return nil;
1919
}
2020

21-
if (hitView != self) {
21+
if (hitView != self || _shouldAllowTapToClose) {
2222
return hitView;
2323
}
2424

0 commit comments

Comments
 (0)