diff --git a/README.md b/README.md index c4206cd..f3fb2d5 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ $ cordova plugin add cordova-plugin-wkwebview --variable WKWEBVIEW_SERVER_PORT=1 No need for anything else - you can now open the project in XCode 6 if you like. ## 4. Changelog +* __0.6.5__ `KeyboardDisplayRequiresUserAction` works! So set to `false` if you want the keyboard to pop up when programmatically focussing an input field. * __0.6.4__ On top of the port preference introduced in 0.6.3 you can now override the default variable when installing this plugin (see 'Installation'). * __0.6.3__ By default the embedded webserver uses port `12344`, but if you want to you can now override that port by setting f.i. `` in `config.xml`. * __0.6.2__ LocalStorage is copied from UIWebView to WKWebView again (iOS location was recently changed as it appears). diff --git a/package.json b/package.json index 7e49302..6fbbe78 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "0.6.4", + "version": "0.6.5", "name": "cordova-plugin-wkwebview", "cordova_name": "WKWebView Polyfill", "description": "A drop-in replacement of UIWebView for boosted performance and enhanced HTML5 support", diff --git a/plugin.xml b/plugin.xml index a34bacc..6d20424 100755 --- a/plugin.xml +++ b/plugin.xml @@ -1,7 +1,7 @@ + version="0.6.5"> WKWebView Polyfill diff --git a/src/ios/MyMainViewController.m b/src/ios/MyMainViewController.m index f7cdc2e..47c1e21 100755 --- a/src/ios/MyMainViewController.m +++ b/src/ios/MyMainViewController.m @@ -1,3 +1,4 @@ +#import #import "MyMainViewController.h" #import #import @@ -392,6 +393,10 @@ - (void)viewDidLoad if ([self.webView respondsToSelector:@selector(setKeyboardDisplayRequiresUserAction:)]) { [self.webView setValue:[NSNumber numberWithBool:keyboardDisplayRequiresUserAction] forKey:@"keyboardDisplayRequiresUserAction"]; } + + if (!keyboardDisplayRequiresUserAction) { + [self keyboardDisplayDoesNotRequireUserAction]; + } } /* @@ -601,6 +606,18 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigati decisionHandler(WKNavigationActionPolicyAllow); } +// this is by far the weirest piece of code I've produced to date (swizzling a private method) +- (void) keyboardDisplayDoesNotRequireUserAction { + SEL sel = sel_getUid("_startAssistingNode:userIsInteracting:blurPreviousNode:userObject:"); + Class WKContentView = NSClassFromString(@"WKContentView"); + Method method = class_getInstanceMethod(WKContentView, sel); + IMP originalImp = method_getImplementation(method); + IMP imp = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, id arg3) { + ((void (*)(id, SEL, void*, BOOL, BOOL, id))originalImp)(me, sel, arg0, TRUE, arg2, arg3); + }); + method_setImplementation(method, imp); +} + #pragma mark WKScriptMessageHandler implementation #ifdef __IPHONE_8_0