ios – 以编程方式关注webview中的表单(WKWebView)

UIWebView可以使用以下内容
[webView setKeyboarddisplayRequiresUserAction:NO]
Call some JS function

如果webview是WKWebView,你怎么能这样做呢?

相关:How can I get a UIWebView to focus on a form input and bring up the keyboard?

解决方法

在深入研究Webkit源代码几周后,我已经设法通过在WKContentView上调用_startAssistingNode:userIsInteracting:blurPrevIoUsNode:userObject并覆盖userIsInteracting值来实现iOS 9的工作:

代码

swizzle_intercept("WKContentView","_startAssistingNode:userIsInteracting:blurPrevIoUsNode:userObject:",&hackAssist);

void hackAssist (id self,SEL _cmd,void* arg0,BOOL arg1,BOOL arg2,id arg3) {
    ((void (*)(id,SEL,void*,BOOL,id))swizzle_interceptee(hackAssist))(self,_cmd,arg0,TRUE,arg2,arg3);
}

干杯!

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...