我正在Swift中制作一个NotePad应用程序,并且遇到了以下问题:
类型“ Notification.Name”(也称为“ NSNotification.Name”)没有成员“ UIResponder”
这些是我键入的代码行:
@objc func updateTextView (notification : Notification) {
let userInfo = notification.userInfo!
let keyboardEndFrameScreenCoordinates = (userInfo[UIResponder.keyboardFrameEndUserInfoKey] as! NSValue).cgRectValue
let keyboardEndFrame = self.view.convert(keyboardEndFrameScreenCoordinates, to: view.window)
if notification.name == Notification.Name.UIResponder.keyboardWillHideNotification {
textView.contentInset = UIEdgeInsets.zero
} else {
textView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: keyboardEndFrame.height, right: 0)
textView.scrollIndicatorInsets = textView.contentInset
}
textView.scrollRangeToVisible(textView.selectedRange)
}
答案 0 :(得分:1)
尝试一下:
if notification.name == UIResponder.keyboardWillHideNotification {
...