WKWebViewの入力フォームでキーボード下部のボタンが反応しない
Swift4.2でWKWebViewを利用したアプリを開発しています。
WebView内の入力フォームで入力する際、iPhoneX系のキーボード下のキーボード切り替え(地球儀マーク)ボタンとマイクボタンがタップしても反応しなくなりました。
地球儀マークのボタンはWKWebViewのインスタンス生成後初回のタップのみ反応し、通常であれば長押しした場合に出てくるキーボード一覧のダイアログが表示されてしまいます。(添付画像参照)
また、初回のタップ時に以下のConstraints関連のエラーが出ます。
原因や解決方法を教えて頂けると助かります。
Swift Code
import UIKit
import WebKit
class DummyViewController: UIViewController {
let wkWebView = WKWebView()
override func viewDidLoad() {
super.viewDidLoad()
wkWebView.frame = view.frame
wkWebView.allowsBackForwardNavigationGestures = true
let urlRequest = URLRequest(url:URL(string: "https://google.com")!)
wkWebView.load(urlRequest)
view.addSubview(wkWebView)
}
}
Error Log
2019-05-20 10:37:20.557422+0900 [LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<NSLayoutConstraint:0x6000032d40a0 'UISV-canvas-connection' UIStackView:0x7ffa8d4960f0.leading == UIInputSwitcherTableCellSegmentView:0x7ffa8d497100.leading (active)>",
"<NSLayoutConstraint:0x6000032d7070 'UISV-canvas-connection' H:[UIInputSwitcherTableCellSegmentView:0x7ffa8d499820]-(0)-| (active, names: '|':UIStackView:0x7ffa8d4960f0 )>",
"<NSLayoutConstraint:0x6000032d77f0 'UISV-fill-equally' UIInputSwitcherTableCellSegmentView:0x7ffa8d498bd0.width == UIInputSwitcherTableCellSegmentView:0x7ffa8d497100.width (active)>",
"<NSLayoutConstraint:0x6000032d7750 'UISV-fill-equally' UIInputSwitcherTableCellSegmentView:0x7ffa8d499820.width == UIInputSwitcherTableCellSegmentView:0x7ffa8d497100.width (active)>",
"<NSLayoutConstraint:0x6000032d6620 'UISV-spacing' H:[UIInputSwitcherTableCellSegmentView:0x7ffa8d497100]-(9)-[UIInputSwitcherTableCellSegmentView:0x7ffa8d498bd0] (active)>",
"<NSLayoutConstraint:0x6000032d6d50 'UISV-spacing' H:[UIInputSwitcherTableCellSegmentView:0x7ffa8d498bd0]-(9)-[UIInputSwitcherTableCellSegmentView:0x7ffa8d499820] (active)>",
"<NSLayoutConstraint:0x6000032d6800 'UIView-Encapsulated-Layout-Width' UIStackView:0x7ffa8d4960f0.width == 0 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x6000032d6d50 'UISV-spacing' H:[UIInputSwitcherTableCellSegmentView:0x7ffa8d498bd0]-(9)-[UIInputSwitcherTableCellSegmentView:0x7ffa8d499820] (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.