swift WKWebViews + keyboardRequiresUserInteraction.swift

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了swift WKWebViews + keyboardRequiresUserInteraction.swift相关的知识,希望对你有一定的参考价值。

import Foundation
import WebKit

typealias ClosureType =  @convention(c) (Any, Selector, UnsafeRawPointer, Bool, Bool, Any) -> Void

extension WKWebView{
    var keyboardDisplayRequiresUserAction: Bool? {
        get {
            return self.keyboardDisplayRequiresUserAction
        }
        set {
            self.setKeyboardRequiresUserInteraction(newValue ?? true)
        }
    }
    
    func setKeyboardRequiresUserInteraction( _ value: Bool) {
        let sel: Selector = sel_getUid("_startAssistingNode:userIsInteracting:blurPreviousNode:userObject:")
        let WKContentView: AnyClass = NSClassFromString("WKContentView")!
        let method = class_getInstanceMethod(WKContentView, sel)
        let originalImp: IMP = method_getImplementation(method)
        let original: ClosureType = unsafeBitCast(originalImp, to: ClosureType.self)
        let block : @convention(block) (Any, UnsafeRawPointer, Bool, Bool, Any) -> Void = { (me, arg0, arg1, arg2, arg3) in
            original(me, sel, arg0, !value, arg2, arg3)
        }
        let imp: IMP = imp_implementationWithBlock(block)
        method_setImplementation(method, imp)
    }
}

以上是关于swift WKWebViews + keyboardRequiresUserInteraction.swift的主要内容,如果未能解决你的问题,请参考以下文章

在 iOS 9 上的多个 WKWebViews 中同步 cookie

为啥我的 WKWebviews 在模拟器上工作,但无法在 iPad 上提取文件?

UITableViewCell 里面有一个 StackView,里面有动态添加的 WKWebViews 和 UIImageViews

iOS 14 上的 WKWebView 仅在显着延迟后加载内容

jq虚拟键盘使用

设置 iPhone 键盘语言