Created
May 30, 2019 22:15
-
-
Save VictorCoding/2958701e023cac915b27d5f295869a2b to your computer and use it in GitHub Desktop.
WKWebview show keyboard when input.focus()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) keyboardDisplayDoesNotRequireUserAction { | |
Class class = NSClassFromString(@"WKContentView"); | |
NSOperatingSystemVersion iOS_11_3_0 = (NSOperatingSystemVersion){11, 3, 0}; | |
NSOperatingSystemVersion iOS_12_2_0 = (NSOperatingSystemVersion){12, 2, 0}; | |
char * methodSignature = "_startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:"; | |
if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_12_2_0]) { | |
methodSignature = "_elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:"; | |
} | |
if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_11_3_0]) { | |
SEL selector = sel_getUid(methodSignature); | |
Method method = class_getInstanceMethod(class, selector); | |
IMP original = method_getImplementation(method); | |
IMP override = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, BOOL arg3, id arg4) { | |
((void (*)(id, SEL, void*, BOOL, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3, arg4); | |
}); | |
method_setImplementation(method, override); | |
} else { | |
SEL selector = sel_getUid("_startAssistingNode:userIsInteracting:blurPreviousNode:userObject:"); | |
Method method = class_getInstanceMethod(class, selector); | |
IMP original = method_getImplementation(method); | |
IMP override = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, id arg3) { | |
((void (*)(id, SEL, void*, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3); | |
}); | |
method_setImplementation(method, override); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment