summaryrefslogtreecommitdiff
path: root/plugins/cordova-plugin-ios-longpress-fix/src/ios/LongPressFix.m
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/cordova-plugin-ios-longpress-fix/src/ios/LongPressFix.m')
-rwxr-xr-xplugins/cordova-plugin-ios-longpress-fix/src/ios/LongPressFix.m35
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