Commit ac1b7ec7 authored by Alex朱枝文's avatar Alex朱枝文

根据H5需要,键盘事件换成willShow和willHide

parent a90f3e0c
...@@ -303,10 +303,10 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD ...@@ -303,10 +303,10 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
} }
getData() getData()
updateNetWorkStatusUI(needReload: false) updateNetWorkStatusUI(needReload: false)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidShow(_:)), NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(_:)),
name: UIResponder.keyboardDidShowNotification, object: nil) name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidHide(_:)), NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)),
name: UIResponder.keyboardDidHideNotification, object: nil) name: UIResponder.keyboardWillHideNotification, object: nil)
} }
...@@ -427,7 +427,7 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD ...@@ -427,7 +427,7 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
previewFileTool.openXLSXRemoteFile(urlString: urlString, fileName: "") previewFileTool.openXLSXRemoteFile(urlString: urlString, fileName: "")
} }
@objc func keyboardDidShow(_ notification: Notification) { @objc func keyboardWillShow(_ notification: Notification) {
guard let userInfo = notification.userInfo, guard let userInfo = notification.userInfo,
let keyboardFrame = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect else { return } let keyboardFrame = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect else { return }
...@@ -437,7 +437,7 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD ...@@ -437,7 +437,7 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
webview.callHandler("onKeyboardHeightChanged", arguments: [dict]) webview.callHandler("onKeyboardHeightChanged", arguments: [dict])
} }
@objc func keyboardDidHide(_ notification: Notification) { @objc func keyboardWillHide(_ notification: Notification) {
// 调用 H5 的 onKeyboardHide 方法 // 调用 H5 的 onKeyboardHide 方法
let dict = ["height": "\(0)"] let dict = ["height": "\(0)"]
webview.callHandler("onKeyboardHeightChanged", arguments: [dict]) webview.callHandler("onKeyboardHeightChanged", arguments: [dict])
......
...@@ -77,10 +77,10 @@ class YHH5WebViewVC: YHBaseViewController, WKUIDelegate, WKNavigationDelegate { ...@@ -77,10 +77,10 @@ class YHH5WebViewVC: YHBaseViewController, WKUIDelegate, WKNavigationDelegate {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
setupUI() setupUI()
NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidShow(_:)), NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(_:)),
name: UIResponder.keyboardDidShowNotification, object: nil) name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidHide(_:)), NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)),
name: UIResponder.keyboardDidHideNotification, object: nil) name: UIResponder.keyboardWillHideNotification, object: nil)
} }
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
...@@ -461,7 +461,7 @@ private extension YHH5WebViewVC { ...@@ -461,7 +461,7 @@ private extension YHH5WebViewVC {
return !disableFullScreenGestureFlag return !disableFullScreenGestureFlag
} }
@objc func keyboardDidShow(_ notification: Notification) { @objc func keyboardWillShow(_ notification: Notification) {
guard let userInfo = notification.userInfo, guard let userInfo = notification.userInfo,
let keyboardFrame = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect else { return } let keyboardFrame = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect else { return }
...@@ -471,7 +471,7 @@ private extension YHH5WebViewVC { ...@@ -471,7 +471,7 @@ private extension YHH5WebViewVC {
webview.callHandler("onKeyboardHeightChanged", arguments: [dict]) webview.callHandler("onKeyboardHeightChanged", arguments: [dict])
} }
@objc func keyboardDidHide(_ notification: Notification) { @objc func keyboardWillHide(_ notification: Notification) {
// 调用 H5 的 onKeyboardHide 方法 // 调用 H5 的 onKeyboardHide 方法
let dict = ["height": "\(0)"] let dict = ["height": "\(0)"]
webview.callHandler("onKeyboardHeightChanged", arguments: [dict]) webview.callHandler("onKeyboardHeightChanged", arguments: [dict])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment