0

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)
}
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Momo
  • 43
  • 1
  • 6

1 Answers1

1

Try this:

if notification.name == UIResponder.keyboardWillHideNotification {

...
alanpaivaa
  • 1,959
  • 1
  • 14
  • 23