diff options
| author | Arjun Roychowdhury <pliablepixels@gmail.com> | 2015-09-23 15:44:19 -0400 |
|---|---|---|
| committer | Arjun Roychowdhury <pliablepixels@gmail.com> | 2015-09-23 15:44:19 -0400 |
| commit | 26821696678cf84ee19f4eb803807e41a7b56780 (patch) | |
| tree | 1503bee984f7e70406e08c22c4fb9aeb0c902ec1 /plugins/cordova-plugin-ios-longpress-fix/src/ios/LongPressFix.m | |
| parent | fe8e827a86ce2304d5deefc4c969d9ea7ce2bd79 (diff) | |
IOS9 patch to remove callout
Diffstat (limited to 'plugins/cordova-plugin-ios-longpress-fix/src/ios/LongPressFix.m')
| -rwxr-xr-x | plugins/cordova-plugin-ios-longpress-fix/src/ios/LongPressFix.m | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/plugins/cordova-plugin-ios-longpress-fix/src/ios/LongPressFix.m b/plugins/cordova-plugin-ios-longpress-fix/src/ios/LongPressFix.m new file mode 100755 index 00000000..9f3d8521 --- /dev/null +++ b/plugins/cordova-plugin-ios-longpress-fix/src/ios/LongPressFix.m @@ -0,0 +1,35 @@ +#import "LongPressFix.h" + +@implementation LongPressFix + +- (void)pluginInitialize { + self.lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPressGestures:)]; + self.lpgr.minimumPressDuration = 0.45f; + self.lpgr.allowableMovement = 100.0f; + + NSArray *views = self.webView.subviews; + if (views.count == 0) { + NSLog(@"No webview subviews found, not applying the longpress fix"); + return; + } + for (int i=0; i<views.count; i++) { + UIView *webViewScrollView = views[i]; + if ([webViewScrollView isKindOfClass:[UIScrollView class]]) { + NSArray *webViewScrollViewSubViews = webViewScrollView.subviews; + UIView *browser = webViewScrollViewSubViews[0]; + [browser addGestureRecognizer:self.lpgr]; + NSLog(@"Applied longpress fix"); + break; + } + } +} + +- (void)handleLongPressGestures:(UILongPressGestureRecognizer *)sender { + if ([sender isEqual:self.lpgr]) { + if (sender.state == UIGestureRecognizerStateBegan) { + NSLog(@"Ignoring a longpress in order to suppress the magnifying glass (iOS9 quirk)"); + } + } +} + +@end
\ No newline at end of file |
