gpt4 book ai didi

swift - iOS11 键盘问题

转载 作者:行者123 更新时间:2023-11-30 12:08:01 24 4
gpt4 key购买 nike

NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardWillHide), name: NSNotification.Name.UIKeyboardWillShow, object: nil)

func keyboardWillHide(notification: NSNotification) {
if let rect = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {

}
}

顺便说一下,函数没有给出正确的 RectValue。这有什么问题吗?

最佳答案

试试这个:

 NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardWillHide), name: NSNotification.Name.UIKeyboardWillHide, object: nil)

NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardWillShow), name: NSNotification.Name.UIKeyboardWillShow, object: nil)

func keyboardWillHide(notification: NSNotification) {
if let rect = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {

}
}
func keyboardWillShow(notification: NSNotification) {
if let rect = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue {

}
}

关于swift - iOS11 键盘问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46459819/

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