【发布时间】:2019-09-11 05:12:25
【问题描述】:
我正在用 Swift 制作记事本应用程序,但遇到以下问题:
类型“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)
}
【问题讨论】:
标签: swift uiresponder