gpt4 book ai didi

ios - 检测 WKWebView 实例内部的事件

转载 作者:行者123 更新时间:2023-11-30 13:50:33 25 4
gpt4 key购买 nike

我知道如何检测 Swift 中显示的正常键盘,但我想知道是否可以检测 WKWebView 内的事件,因为...如果应用程序进入后台,输入失去焦点,但不会触发“模糊”事件。

这个想法是,我在应用程序中有一个“导航栏”,当显示键盘时,它会被推出 View (向上),并且我想继续显示它。知道键盘大约有 216px 高,我只想将基于 flex 内容包装器 的高度缩小 216px 但这并没有真正起作用,因为它是一个我无法真正重现的动画,所以它很流畅。我也无法检测用户何时进入 emoji 选项卡。我摆脱了自动更正,因为我只是将input 标记的off 设置为off

最佳答案

试试这个代码。

override viewWillAppear(){
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillShow:"), name:UIKeyboardWillShowNotification, object: nil);
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillHide"), name:UIKeyboardWillHideNotification, object: nil);
}

func keyboardWillHide(){
navigationController?.setNavigationBarHidden(false, animated: true)
}

func keyboardWillShow(notification: NSNotification) {
navigationController?.setNavigationBarHidden(true, animated: true)
var info = notification.userInfo!
var keyboardFrame: CGRect = (info[UIKeyboardFrameEndUserInfoKey] as! NSValue).CGRectValue()
// handle your layout according to frame
}

关于ios - 检测 WKWebView 实例内部的事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34339276/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com