WKWebView中的键盘开关按钮和麦克风按钮不响应

时间:2019-05-20 03:37:10

标签: ios swift webview wkwebview

点击WKWebView中的键盘开关按钮或麦克风按钮时,会弹出约束错误。

快捷代码

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)
  }
}

错误日志

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.

0 个答案:

没有答案