This question already has an answer here:
I'm making a NotePad application in Swift and I get the following issue:
type 'Notification.Name' (aka 'NSNotification.Name') has no member 'UIResponder'
Those are the lines of code I typed on:
@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)
}
Try this: