gpt4 book ai didi

ios - 类型“NSNotification.Name”没有成员“keyboardDidShowNotification”

转载 作者:行者123 更新时间:2023-11-29 05:36:31 25 4
gpt4 key购买 nike

我在Swift 4.2中遇到此错误


  类型“ NSNotification.Name”没有成员“ keyboardDidShowNotification”


这是我的代码:

NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardDidShow(notification:)), name: NSNotification.Name.keyboardDidShowNotification, object: nil)


下一个可以在Swift 4上正常工作,但不能在Swift 4.2上正常工作

NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardDidShow(notification:)), name: NSNotification.Name.UIKeyboardDidShow, object: nil)


enter image description here

Apple文件编号: NSNotification.Name.keyboardDidShowNotification

最佳答案

我相信您现在就这样使用它。

NotificationCenter.default.addObserver(
self,
selector: #selector(self.keyboardDidShow(notification:)),
name: UIResponder.keyboardDidShowNotification, object: nil)

/* You can substitute UIResponder with any of it's subclass */


它在 UIResponder doc中作为类型属性列出。

关于ios - 类型“NSNotification.Name”没有成员“keyboardDidShowNotification”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56989114/

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