【问题标题】:How to fix this issue with the UIResponder as not recognized? [duplicate]如何解决 UIResponder 无法识别的问题? [复制]
【发布时间】: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


    【解决方案1】:

    试试这个:

    if notification.name == UIResponder.keyboardWillHideNotification {
    
    ...
    

    【讨论】:

      猜你喜欢
      • 2015-03-18
      • 2019-05-05
      • 1970-01-01
      • 1970-01-01
      • 2019-10-21
      • 2021-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多