以编程方式关注webview中的表单(WKWebView) [英] Programmatically focus on a form in a webview (WKWebView)

查看:370
本文介绍了以编程方式关注webview中的表单(WKWebView)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UIWebView可以使用以下内容:

It's possible with UIWebView with following:

[webView setKeyboardDisplayRequiresUserAction:NO]
Call some JS function

当webview WKWebView 相反?

How can you do the same when the webview is WKWebView instead?

相关:如何让UIWebView专注于表单输入并调出键盘?

推荐答案

在深入研究Webkit源数周后,我已经设法通过调整来实现iOS 9的工作_startAssistingNode:userIsInteracting:blurPreviousNode:userObject on WKContentView 并覆盖userIsInteracting值:

After digging into the Webkit sources for a couple of weeks, I've managed to get this working on iOS 9 by swizzling _startAssistingNode:userIsInteracting:blurPreviousNode:userObject on WKContentView and overriding the userIsInteracting value:

伪代码:

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,BOOL,id))swizzle_interceptee(hackAssist))(self, _cmd, arg0, TRUE, arg2, arg3);
}

干杯!

这篇关于以编程方式关注webview中的表单(WKWebView)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆