swift - iOSDropDown : Type 'UIResponder' has no member 'NSNotification'

标签 swift xcode

更新到 Catalina 和 pod update 后我收到错误

Type 'UIResponder' has no member 'NSNotification'

这是给 iOSDropDown

if isSearchEnable && handleKeyboard{
        NotificationCenter.default.addObserver(forName: UIResponder.NSNotification.Name.UIKeyboardWillShow, object: nil, queue: nil) { (notification) in
            if self.isFirstResponder{
            let userInfo:NSDictionary = notification.userInfo! as NSDictionary
                let keyboardFrame:NSValue = userInfo.value(forKey: UIResponder.UIKeyboardFrameEndUserInfoKey) as! NSValue
            let keyboardRectangle = keyboardFrame.cgRectValue
            self.keyboardHeight = keyboardRectangle.height
                if !self.isSelected{
                    self.showList()
                }
            }

        }
        NotificationCenter.default.addObserver(forName: UIResponder.NSNotification.Name.UIKeyboardWillHide, object: nil, queue: nil) { (notification) in
            if self.isFirstResponder{
            self.keyboardHeight = 0
            }
        }
    }

最佳答案

您现在将在UIResponder 上直接使用keyboardWillShowNotification,如前所述here类型属性下,

NotificationCenter.default.addObserver(forName: UIResponder.keyboardWillShowNotification, object: nil, queue: nil)

注意:由于错误出现在外部库中,您可以fork 库,解决问题并在 podfile 中指向您的 fork 版本。或者,您可以选择在本地计算机上进行更改,但每次您执行 pod update 时它都会被覆盖。

关于swift - iOSDropDown : Type 'UIResponder' has no member 'NSNotification' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58361534/

相关文章:

iOS Swift - 如何隐藏 UIView 元素并占用空间?

应用程序中使用 iPhone 相机进行扫描(如红色激光)

xcode - 如何制作具有步长值的 UISlider

objective-c - 如何构建和归档 iOS 应用程序?

ios - IBAN 验证器 Swift

swift - 如何在 Swift MacOS 中通过 Process 执行多个命令

ios - 使用下一个和上一个按钮在 VC 中显示有序句子

swift - 更改 GameViewController 中必须首先执行的场景后出错

objective-c - Mac 应用程序 - 禁用特定 USB 端口

ios - UICollectionViewCell 叠加 View