如果在显示WKWebView时打开键盘,它将自动将AdjustedContentInset添加到ScrollView。但是问题是,如果我自己操作键盘,它仍然会添加AdjustedContentInset。我该如何解决?
答案 0 :(得分:1)
如果从WKWebView中删除处理键盘的观察者,它将停止添加AdjustedContentInset:
NotificationCenter.default.removeObserver(self.webView, name: UIResponder.keyboardWillChangeFrameNotification, object: nil)
NotificationCenter.default.removeObserver(self.webView, name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.removeObserver(self.webView, name: UIResponder.keyboardWillHideNotification, object: nil)