Open panychyk opened 4 years ago
this workaround worked for me.
editor.webView.becomeFirstResponder()
editor.focus(at: .zero)
editor.webView.becomeFirstResponder()
editor.focus(at: .zero)
Not working for me iOS 14.
I need to open the keyboard when the view appears. Is there any update about the issue?
I am facing similar issue, any solutions to this, note: I am calling RichEditor inside SwiftUI view.
Not working in iOS 15
does any one found solution ?
try this
extension WKWebView {
func setKeyboardRequiresUserInteraction( _ value: Bool) {
guard let WKContentViewClass = NSClassFromString("WKContentView") else { return }
typealias OlderClosureType = @convention(c) (Any, Selector, UnsafeRawPointer, Bool, Bool, Any?) -> Void
typealias NewerClosureType = @convention(c) (Any, Selector, UnsafeRawPointer, Bool, Bool, Bool, Any?) -> Void
let olderSelector = sel_getUid("_startAssistingNode:userIsInteracting:blurPreviousNode:userObject:")
let iOS12_2Selector = sel_getUid("_elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:")
let iOS13Selector = sel_getUid("_elementDidFocus:userIsInteracting:blurPreviousNode:activityStateChanges:userObject:")
if let method = class_getInstanceMethod(WKContentViewClass, iOS13Selector) {
let originalImp: IMP = method_getImplementation(method)
let original: NewerClosureType = unsafeBitCast(originalImp, to: NewerClosureType.self)
let block : @convention(block) (Any, UnsafeRawPointer, Bool, Bool, Bool, Any?) -> Void = { (me, arg0, arg1, arg2, arg3, arg4) in
original(me, iOS13Selector, arg0, !value, arg2, arg3, arg4)
}
let imp: IMP = imp_implementationWithBlock(block)
method_setImplementation(method, imp)
} else if let method = class_getInstanceMethod(WKContentViewClass, iOS12_2Selector) {
let originalImp: IMP = method_getImplementation(method)
let original: NewerClosureType = unsafeBitCast(originalImp, to: NewerClosureType.self)
let block : @convention(block) (Any, UnsafeRawPointer, Bool, Bool, Bool, Any?) -> Void = { (me, arg0, arg1, arg2, arg3, arg4) in
original(me, iOS12_2Selector, arg0, !value, arg2, arg3, arg4)
}
let imp: IMP = imp_implementationWithBlock(block)
method_setImplementation(method, imp)
} else if let method = class_getInstanceMethod(WKContentViewClass, olderSelector) {
let originalImp: IMP = method_getImplementation(method)
let original: OlderClosureType = unsafeBitCast(originalImp, to: OlderClosureType.self)
let block : @convention(block) (Any, UnsafeRawPointer, Bool, Bool, Any?) -> Void = { (me, arg0, arg1, arg2, arg3) in
original(me, olderSelector, arg0, !value, arg2, arg3)
}
let imp: IMP = imp_implementationWithBlock(block)
method_setImplementation(method, imp)
}
}
}
editorView.focus() not work on iOS 11