1
1
#import " CDVWKWebViewEngine+InputFocusFix.h"
2
+ #import < objc/runtime.h>
2
3
3
4
@implementation CDVWKWebViewEngine (InputFocusFix)
4
5
+ (void ) load {
@@ -17,14 +18,27 @@ - (void) swizzleWKContentViewForInputFocus {
17
18
}
18
19
19
20
// https://github.com/Telerik-Verified-Plugins/WKWebView/commit/04e8296adeb61f289f9c698045c19b62d080c7e3
21
+ // https://stackoverflow.com/a/48623286/3297914
20
22
- (void ) keyboardDisplayDoesNotRequireUserAction {
21
- SEL sel = sel_getUid (" _startAssistingNode:userIsInteracting:blurPreviousNode:userObject:" );
22
- Class WKContentView = NSClassFromString (@" WKContentView" );
23
- Method method = class_getInstanceMethod (WKContentView, sel);
24
- IMP originalImp = method_getImplementation (method);
25
- IMP imp = imp_implementationWithBlock (^void (id me, void * arg0, BOOL arg1, BOOL arg2, id arg3) {
26
- ((void (*)(id , SEL , void *, BOOL , BOOL , id ))originalImp)(me, sel, arg0, TRUE , arg2, arg3);
27
- });
28
- method_setImplementation (method, imp);
23
+ Class class = NSClassFromString (@" WKContentView" );
24
+ NSOperatingSystemVersion iOS_11_3_0 = (NSOperatingSystemVersion ){11 , 3 , 0 };
25
+
26
+ if ([[NSProcessInfo processInfo ] isOperatingSystemAtLeastVersion: iOS_11_3_0]) {
27
+ SEL selector = sel_getUid (" _startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:" );
28
+ Method method = class_getInstanceMethod (class, selector);
29
+ IMP original = method_getImplementation (method);
30
+ IMP override = imp_implementationWithBlock (^void (id me, void * arg0, BOOL arg1, BOOL arg2, BOOL arg3, id arg4) {
31
+ ((void (*)(id , SEL , void *, BOOL , BOOL , BOOL , id ))original)(me, selector, arg0, TRUE , arg2, arg3, arg4);
32
+ });
33
+ method_setImplementation (method, override);
34
+ } else {
35
+ SEL selector = sel_getUid (" _startAssistingNode:userIsInteracting:blurPreviousNode:userObject:" );
36
+ Method method = class_getInstanceMethod (class, selector);
37
+ IMP original = method_getImplementation (method);
38
+ IMP override = imp_implementationWithBlock (^void (id me, void * arg0, BOOL arg1, BOOL arg2, id arg3) {
39
+ ((void (*)(id , SEL , void *, BOOL , BOOL , id ))original)(me, selector, arg0, TRUE , arg2, arg3);
40
+ });
41
+ method_setImplementation (method, override);
42
+ }
29
43
}
30
- @end
44
+ @end
0 commit comments